Skip to content

Commit

Permalink
working with simctl sleep 10
Browse files Browse the repository at this point in the history
  • Loading branch information
ShepardSiegel committed Sep 30, 2012
1 parent edd91a5 commit 042cd31
Show file tree
Hide file tree
Showing 28 changed files with 6,185 additions and 3,162 deletions.
Binary file modified bin/ocpihdl
Binary file not shown.
Binary file added bin/simctl
Binary file not shown.
Binary file added bin/simctl_nosleep
Binary file not shown.
Binary file added bin/simctl_sleep10
Binary file not shown.
85 changes: 67 additions & 18 deletions bsv/tst/SimIO.bsv
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// SimIO.bsv - Routines to read requests from and write responses to named pipes
// Copyright (c) 2012 Atomic Rules LLC - ALL RIGHTS RESERVED

import Accum ::*;

import Connectable ::*;
import ClientServer ::*;
import FIFOF ::*;
import FIFO ::*;
import GetPut ::*;

interface SimIOIfc;
Expand All @@ -15,42 +17,81 @@ module mkSimIO (SimIOIfc);

UInt#(16) skipAmt = 32;

Reg#(Maybe#(File)) r_hdl <- mkReg(tagged Invalid); // file read handle
Reg#(Maybe#(File)) w_hdl <- mkReg(tagged Invalid); // file write handle
Reg#(Bit#(32)) h2cpByteCount <- mkReg(0); // Host to Control Plane Byte Count
Reg#(Bit#(32)) cp2hByteCount <- mkReg(0); // Control Plane to Host Byte Count
FIFOF#(Bit#(8)) reqF <- mkFIFOF; // input queue from host
FIFOF#(Bit#(8)) respF <- mkFIFOF; // output queue ito host
Reg#(UInt#(16)) skipCnt <- mkReg(skipAmt);
Reg#(Maybe#(File)) s_hdl <- mkReg(tagged Invalid); // file read IOCTL handle
Reg#(Maybe#(File)) r_hdl <- mkReg(tagged Invalid); // file read DCP handle
Reg#(Maybe#(File)) w_hdl <- mkReg(tagged Invalid); // file write handle
Reg#(Bit#(32)) h2ioByteCount <- mkReg(0); // Host to IOCTL Byte Count
Reg#(Bit#(32)) h2cpByteCount <- mkReg(0); // Host to Control Plane Byte Count
Reg#(Bit#(32)) cp2hByteCount <- mkReg(0); // Control Plane to Host Byte Count
FIFO#(Bit#(8)) reqF <- mkFIFO; // input queue from host
FIFO#(Bit#(8)) respF <- mkFIFO; // output queue ito host
Accumulator2Ifc#(Int#(16)) spinCredit <- mkAccumulator2; // Spin credits
Accumulator2Ifc#(Int#(16)) dcpCredit <- mkAccumulator2; // DCP read credits
Reg#(Bool) doTerminate <- mkReg(False);
Reg#(Bool) isOpcode <- mkReg(True);
Reg#(Bit#(8)) ioOpcode <- mkRegU;

rule skipUpdate;
skipCnt <= (skipCnt==0) ? skipAmt : skipCnt-1;
rule passTime (spinCredit>0);
spinCredit.acc2(-1);
$display("[%0d]: passing time - spinCredit:%0d dcpCredit:%0d", $time, spinCredit, dcpCredit);
endrule

rule do_w_open (w_hdl matches tagged Invalid); // Open response channel first
let hdl <- $fopen("/tmp/OpenCPI0_Resp", "w");
w_hdl <= tagged Valid hdl;
$display("[%0d]: do_w_open called", $time);
endrule

rule do_r_open (r_hdl matches tagged Invalid);
rule do_s_open (s_hdl matches tagged Invalid &&& isValid(w_hdl)); // Then IOCTL reads
let hdl <- $fopen("/tmp/OpenCPI0_IOCtl", "r");
s_hdl <= tagged Valid hdl;
spinCredit.load(2); // Must init to two so we can accept the first 2B instruction
dcpCredit.load(0);
$display("[%0d]: do_s_open called", $time);
endrule

rule do_r_open (r_hdl matches tagged Invalid &&& isValid(s_hdl)); // Then DCP requests
let hdl <- $fopen("/tmp/OpenCPI0_Req", "r");
r_hdl <= tagged Valid hdl;
$display("[%0d]: do_r_open called", $time);
endrule

rule do_w_open (w_hdl matches tagged Invalid);
let hdl <- $fopen("/tmp/OpenCPI0_Resp", "w");
w_hdl <= tagged Valid hdl;
rule do_s_char (s_hdl matches tagged Valid .hdl &&& (spinCredit==0));
int i <- $fgetc(hdl);
if (i == -1) begin
$display("[%0d]: do_s_char IOCTL fgetc returned -1 after %0d Bytes", $time, h2ioByteCount);
$fclose(hdl);
s_hdl <= tagged Invalid;
end else begin
Bit#(8) c = truncate(pack(i));
h2ioByteCount <= h2ioByteCount + 1;
$display("[%0d]: get_ioctl read 0x%x Host->Simulator ioctl_readCount:%0d ", $time, c, h2ioByteCount);
isOpcode <= !isOpcode;
if (isOpcode) begin
ioOpcode <= c;
end else begin
case (ioOpcode)
0 : spinCredit.acc1(unpack(extend(c)));
1 : dcpCredit.acc1(unpack(extend(c)));
255 : doTerminate <= True;
endcase
end
end
endrule

//rule do_r_char (r_hdl matches tagged Valid .hdl &&& skipCnt==0 &&& !respF.notEmpty); // only get if respF is EMPTY!
rule do_r_char (r_hdl matches tagged Valid .hdl &&& skipCnt==0);
rule do_r_char (r_hdl matches tagged Valid .hdl &&& (dcpCredit>0));
int i <- $fgetc(hdl);
if (i == -1) begin
$display("[%0d]: do_r_char fgetc returned -1 after %0d Bytes", $time, h2cpByteCount);
$display("[%0d]: do_r_char DCP fgetc returned -1 after %0d Bytes", $time, h2cpByteCount);
$fclose(hdl);
r_hdl <= tagged Invalid;
end
else begin
Bit#(8) c = truncate(pack(i));
h2cpByteCount <= h2cpByteCount + 1;
//$display("[%0d]: get_cp read 0x%x Host->Simulator request_readCount:%0d ", $time, c, h2cpByteCount);
$display("[%0d]: get_cp read 0x%x Host->Simulator DCP request_readCount:%0d ", $time, c, h2cpByteCount);
reqF.enq(c);
dcpCredit.acc2(-1);
end
endrule

Expand All @@ -62,6 +103,14 @@ module mkSimIO (SimIOIfc);
$display("[%0d]: get_cp write 0x%x Simulator->Host response_writeCount:%0d ", $time, c, cp2hByteCount);
endrule

rule do_terminate (doTerminate);
$display("[%0d]: doTerminate called by IOCTL channel", $time);
$display("[%0d]: IOCTL Bytes Read :%0d", $time, h2ioByteCount);
$display("[%0d]: DCP Bytes Read :%0d", $time, h2cpByteCount);
$display("[%0d]: DCP Bytes Written :%0d", $time, cp2hByteCount);
$finish;
endrule

interface Client host;
interface request = toGet(reqF);
interface response = toPut(respF);
Expand Down
2 changes: 1 addition & 1 deletion bsv/tst/TB18.bsv
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module mkTB18();
simCycle <= simCycle + 1;
endrule

rule terminate (simCycle==10000);
rule terminate (simCycle==64000);
$display("[%0d]: %m: mkTB18 termination by terminate rule (timeout)", $time);
$finish;
endrule
Expand Down
130 changes: 65 additions & 65 deletions foop2
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ badd +59 bsv/tst/TB16.bsv
badd +39 bsv/tst/TB17.bsv
badd +68 bsv/tst/SimIO.bsv
badd +176 bsv/eth/EDCP.bsv
badd +523 Makefile
badd +268 Makefile
badd +100 rtl/mkTB17.v
badd +1 rtl/mkSimIO
badd +1 rtl/mkSimIO.v
Expand All @@ -59,7 +59,7 @@ badd +54 bsv/inf/OCCP.bsv
badd +164 bsv/eth/SimDCP.bsv
badd +1 bin/send_dcp_nop.py
badd +1 $
badd +0 bsv/inf/CPDefs.bsv
badd +1 bsv/inf/CPDefs.bsv
args bsv/tst/TB16.bsv
edit Makefile
set splitbelow splitright
Expand Down Expand Up @@ -109,34 +109,34 @@ set nosplitbelow
set nosplitright
wincmd t
set winheight=1 winwidth=1
exe '1resize ' . ((&lines * 29 + 58) / 116)
exe 'vert 1resize ' . ((&columns * 119 + 152) / 304)
exe '1resize ' . ((&lines * 10 + 58) / 116)
exe 'vert 1resize ' . ((&columns * 167 + 143) / 287)
exe '2resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 2resize ' . ((&columns * 119 + 152) / 304)
exe 'vert 2resize ' . ((&columns * 167 + 143) / 287)
exe '3resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 3resize ' . ((&columns * 119 + 152) / 304)
exe 'vert 3resize ' . ((&columns * 167 + 143) / 287)
exe '4resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 4resize ' . ((&columns * 119 + 152) / 304)
exe 'vert 4resize ' . ((&columns * 167 + 143) / 287)
exe '5resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 5resize ' . ((&columns * 119 + 152) / 304)
exe 'vert 5resize ' . ((&columns * 167 + 143) / 287)
exe '6resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 6resize ' . ((&columns * 119 + 152) / 304)
exe 'vert 6resize ' . ((&columns * 167 + 143) / 287)
exe '7resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 7resize ' . ((&columns * 119 + 152) / 304)
exe '8resize ' . ((&lines * 36 + 58) / 116)
exe 'vert 8resize ' . ((&columns * 119 + 152) / 304)
exe '9resize ' . ((&lines * 35 + 58) / 116)
exe 'vert 9resize ' . ((&columns * 119 + 152) / 304)
exe '10resize ' . ((&lines * 18 + 58) / 116)
exe 'vert 10resize ' . ((&columns * 184 + 152) / 304)
exe '11resize ' . ((&lines * 22 + 58) / 116)
exe 'vert 11resize ' . ((&columns * 184 + 152) / 304)
exe '12resize ' . ((&lines * 4 + 58) / 116)
exe 'vert 12resize ' . ((&columns * 184 + 152) / 304)
exe '13resize ' . ((&lines * 65 + 58) / 116)
exe 'vert 13resize ' . ((&columns * 184 + 152) / 304)
exe '14resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 14resize ' . ((&columns * 184 + 152) / 304)
exe 'vert 7resize ' . ((&columns * 167 + 143) / 287)
exe '8resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 8resize ' . ((&columns * 167 + 143) / 287)
exe '9resize ' . ((&lines * 89 + 58) / 116)
exe 'vert 9resize ' . ((&columns * 167 + 143) / 287)
exe '10resize ' . ((&lines * 75 + 58) / 116)
exe 'vert 10resize ' . ((&columns * 119 + 143) / 287)
exe '11resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 11resize ' . ((&columns * 119 + 143) / 287)
exe '12resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 12resize ' . ((&columns * 119 + 143) / 287)
exe '13resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 13resize ' . ((&columns * 119 + 143) / 287)
exe '14resize ' . ((&lines * 32 + 58) / 116)
exe 'vert 14resize ' . ((&columns * 119 + 143) / 287)
argglobal
setlocal noarabic
setlocal autoindent
Expand Down Expand Up @@ -234,7 +234,7 @@ setlocal nowinfixwidth
setlocal wrap
setlocal wrapmargin=0
silent! normal! zE
let s:l = 268 - ((13 * winheight(0) + 14) / 29)
let s:l = 268 - ((0 * winheight(0) + 5) / 10)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
Expand Down Expand Up @@ -969,7 +969,7 @@ setlocal nowinfixwidth
setlocal wrap
setlocal wrapmargin=0
silent! normal! zE
let s:l = 178 - ((15 * winheight(0) + 18) / 36)
let s:l = 178 - ((0 * winheight(0) + 0) / 1)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
Expand Down Expand Up @@ -1074,12 +1074,12 @@ setlocal nowinfixwidth
setlocal wrap
setlocal wrapmargin=0
silent! normal! zE
let s:l = 16 - ((7 * winheight(0) + 17) / 35)
let s:l = 36 - ((25 * winheight(0) + 44) / 89)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
16
normal! 023l
36
normal! 062l
wincmd w
argglobal
edit rtl/mkSimIO.v
Expand Down Expand Up @@ -1179,12 +1179,12 @@ setlocal nowinfixwidth
setlocal wrap
setlocal wrapmargin=0
silent! normal! zE
let s:l = 217 - ((2 * winheight(0) + 9) / 18)
let s:l = 423 - ((74 * winheight(0) + 37) / 75)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
217
normal! 025l
423
normal! 019l
wincmd w
argglobal
edit bsv/eth/SimDCP.bsv
Expand Down Expand Up @@ -1284,12 +1284,12 @@ setlocal nowinfixwidth
setlocal wrap
setlocal wrapmargin=0
silent! normal! zE
let s:l = 170 - ((11 * winheight(0) + 11) / 22)
let s:l = 48 - ((0 * winheight(0) + 0) / 1)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
170
normal! 08l
48
normal! 017l
wincmd w
argglobal
edit bsv/inf/CPDefs.bsv
Expand Down Expand Up @@ -1389,7 +1389,7 @@ setlocal nowinfixwidth
setlocal wrap
setlocal wrapmargin=0
silent! normal! zE
let s:l = 4 - ((0 * winheight(0) + 2) / 4)
let s:l = 4 - ((0 * winheight(0) + 0) / 1)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
Expand Down Expand Up @@ -1494,12 +1494,12 @@ setlocal nowinfixwidth
setlocal wrap
setlocal wrapmargin=0
silent! normal! zE
let s:l = 111 - ((28 * winheight(0) + 32) / 65)
let s:l = 95 - ((0 * winheight(0) + 0) / 1)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
111
normal! 021l
95
normal! 073l
wincmd w
argglobal
edit bsv/tst/TB18.bsv
Expand Down Expand Up @@ -1599,42 +1599,42 @@ setlocal nowinfixwidth
setlocal wrap
setlocal wrapmargin=0
silent! normal! zE
let s:l = 45 - ((0 * winheight(0) + 0) / 1)
let s:l = 62 - ((22 * winheight(0) + 16) / 32)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
45
normal! 054l
62
normal! 016l
wincmd w
13wincmd w
exe '1resize ' . ((&lines * 29 + 58) / 116)
exe 'vert 1resize ' . ((&columns * 119 + 152) / 304)
9wincmd w
exe '1resize ' . ((&lines * 10 + 58) / 116)
exe 'vert 1resize ' . ((&columns * 167 + 143) / 287)
exe '2resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 2resize ' . ((&columns * 119 + 152) / 304)
exe 'vert 2resize ' . ((&columns * 167 + 143) / 287)
exe '3resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 3resize ' . ((&columns * 119 + 152) / 304)
exe 'vert 3resize ' . ((&columns * 167 + 143) / 287)
exe '4resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 4resize ' . ((&columns * 119 + 152) / 304)
exe 'vert 4resize ' . ((&columns * 167 + 143) / 287)
exe '5resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 5resize ' . ((&columns * 119 + 152) / 304)
exe 'vert 5resize ' . ((&columns * 167 + 143) / 287)
exe '6resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 6resize ' . ((&columns * 119 + 152) / 304)
exe 'vert 6resize ' . ((&columns * 167 + 143) / 287)
exe '7resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 7resize ' . ((&columns * 119 + 152) / 304)
exe '8resize ' . ((&lines * 36 + 58) / 116)
exe 'vert 8resize ' . ((&columns * 119 + 152) / 304)
exe '9resize ' . ((&lines * 35 + 58) / 116)
exe 'vert 9resize ' . ((&columns * 119 + 152) / 304)
exe '10resize ' . ((&lines * 18 + 58) / 116)
exe 'vert 10resize ' . ((&columns * 184 + 152) / 304)
exe '11resize ' . ((&lines * 22 + 58) / 116)
exe 'vert 11resize ' . ((&columns * 184 + 152) / 304)
exe '12resize ' . ((&lines * 4 + 58) / 116)
exe 'vert 12resize ' . ((&columns * 184 + 152) / 304)
exe '13resize ' . ((&lines * 65 + 58) / 116)
exe 'vert 13resize ' . ((&columns * 184 + 152) / 304)
exe '14resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 14resize ' . ((&columns * 184 + 152) / 304)
exe 'vert 7resize ' . ((&columns * 167 + 143) / 287)
exe '8resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 8resize ' . ((&columns * 167 + 143) / 287)
exe '9resize ' . ((&lines * 89 + 58) / 116)
exe 'vert 9resize ' . ((&columns * 167 + 143) / 287)
exe '10resize ' . ((&lines * 75 + 58) / 116)
exe 'vert 10resize ' . ((&columns * 119 + 143) / 287)
exe '11resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 11resize ' . ((&columns * 119 + 143) / 287)
exe '12resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 12resize ' . ((&columns * 119 + 143) / 287)
exe '13resize ' . ((&lines * 1 + 58) / 116)
exe 'vert 13resize ' . ((&columns * 119 + 143) / 287)
exe '14resize ' . ((&lines * 32 + 58) / 116)
exe 'vert 14resize ' . ((&columns * 119 + 143) / 287)
tabnext 1
if exists('s:wipebuf')
silent exe 'bwipe ' . s:wipebuf
Expand Down
2 changes: 1 addition & 1 deletion rtl/mkBiasWorker16B.v
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Generated by Bluespec Compiler, version 2012.09.beta1 (build 29570, 2012-09.11)
//
// On Sun Sep 30 09:11:07 EDT 2012
// On Sun Sep 30 18:25:54 EDT 2012
//
//
// Ports:
Expand Down
2 changes: 1 addition & 1 deletion rtl/mkBiasWorker32B.v
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Generated by Bluespec Compiler, version 2012.09.beta1 (build 29570, 2012-09.11)
//
// On Sun Sep 30 09:11:09 EDT 2012
// On Sun Sep 30 18:25:55 EDT 2012
//
//
// Ports:
Expand Down
2 changes: 1 addition & 1 deletion rtl/mkBiasWorker4B.v
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Generated by Bluespec Compiler, version 2012.09.beta1 (build 29570, 2012-09.11)
//
// On Sun Sep 30 09:11:05 EDT 2012
// On Sun Sep 30 18:25:52 EDT 2012
//
//
// Ports:
Expand Down
Loading

0 comments on commit 042cd31

Please sign in to comment.