aboutsummaryrefslogtreecommitdiff
path: root/test/chisel3/Sum.fir
blob: 9eed61092b9dd0e5cd37d91cdfd6e41ad7ff50ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
; RUN: firrtl -i %s -o %s.v -X verilog -p c | tee %s.out | FileCheck %s
;CHECK: Done!

circuit SumTop :
   module Sum :
      input sreq : {valid : UInt<1>, bits : {v : UInt<32>, len : UInt<32>}, flip ready : UInt<1>}
      output srsp : {valid : UInt<1>, bits : {data : UInt<32>}, flip ready : UInt<1>}
      input mrsp : {valid : UInt<1>, bits : {tag : UInt<8>, data : UInt<32>}, flip ready : UInt<1>}
      output mreq : {valid : UInt<1>, bits : {wr? : UInt<1>, tag : UInt<8>, addr : UInt<32>, data : UInt<32>}, flip ready : UInt<1>}
      reg a2 : UInt<32>
      reg ea3 : UInt<32>
      reg sum4 : UInt<32>
      reg num_reqs5 : UInt<?>
      on-reset num_reqs5 := UInt<8>(0)
      reg computing?6 : UInt<?>
      on-reset computing?6 := UInt<1>(0)
      mrsp.ready := UInt<1>(1)
      sreq.ready := UInt<1>(1)
      srsp.valid := UInt<1>(0)
      srsp.bits.data := UInt<1>(0)
      mrsp.ready := UInt<1>(1)
      mreq.bits.wr? := UInt<1>(0)
      mreq.bits.data := UInt<1>(0)
      mreq.bits.addr := UInt<1>(0)
      mreq.valid := UInt<1>(0)
      mreq.bits.tag := UInt<1>(0)
      when computing?6 :
         sreq.ready := UInt<1>(0)
         when mrsp.valid :
            node tmp7 = add-wrap(sum4, mrsp.bits.data)
            sum4 := tmp7         
         node tmp8 = lt(a2, ea3)
         when tmp8 :
            mreq.valid := UInt<1>(1)
            mreq.bits.addr := a2
            when mreq.ready :
               node tmp9 = add-wrap(a2, UInt<1>(1))
               a2 := tmp9         
         else :            
            node tmp10 = eq(num_reqs5, UInt<1>(0))
            when tmp10 :
               srsp.valid := UInt<1>(1)
               srsp.bits.data := sum4
               when srsp.ready :
                  sum4 := UInt<1>(0)
                  computing?6 := UInt<1>(0)      
      else :
         when sreq.valid :
            a2 := sreq.bits.v
            node tmp11 = add-wrap(sreq.bits.v, sreq.bits.len)
            ea3 := tmp11   
   module Memory :
      input req : {valid : UInt<1>, bits : {wr? : UInt<1>, tag : UInt<8>, addr : UInt<32>, data : UInt<32>}, flip ready : UInt<1>}
      output rsp : {valid : UInt<1>, bits : {tag : UInt<8>, data : UInt<32>}, flip ready : UInt<1>}
      cmem mem13 : UInt<32>[8]
      req.ready := rsp.ready
      rsp.valid := UInt<1>(0)
      rsp.bits.data := UInt<1>(0)
      rsp.bits.tag := UInt<1>(0)
      when req.valid :
         rsp.valid := UInt<1>(1)
         rsp.bits.tag := req.bits.tag
         when req.bits.wr? :
            rsp.bits.data := req.bits.data
            accessor a14 = mem13[req.bits.addr]
            a14 := req.bits.data         
         else :
            accessor a15 = mem13[req.bits.addr]
            rsp.bits.data := a15   
   module ArbiterRR :
      input in : {valid : UInt<1>, bits : {wr? : UInt<1>, tag : UInt<8>, addr : UInt<32>, data : UInt<32>}, flip ready : UInt<1>}[2]
      output out : {valid : UInt<1>, bits : {wr? : UInt<1>, tag : UInt<8>, addr : UInt<32>, data : UInt<32>}, flip ready : UInt<1>}
      output chosen : UInt<2>
      reg last-grant17 : UInt<?>
      on-reset last-grant17 := UInt<2>(0)
      node tmp19 = bit-and(in[0].valid, UInt<1>(0))
      node tmp20 = gt(tmp19, last-grant17)
      node tmp21 = bit-and(in[1].valid, UInt<1>(1))
      node tmp22 = gt(tmp21, last-grant17)
      node tmp25 = bit-or(UInt<1>(0), tmp20)
      node tmp26 = bit-not(tmp25)
      node tmp28 = bit-or(UInt<1>(0), tmp20)
      node tmp29 = bit-or(tmp28, tmp22)
      node tmp30 = bit-not(tmp29)
      node tmp32 = bit-or(UInt<1>(0), tmp20)
      node tmp33 = bit-or(tmp32, tmp22)
      node tmp34 = bit-or(tmp33, in[0].valid)
      node tmp35 = bit-not(tmp34)
      node tmp36 = bit-and(UInt<1>(1), UInt<1>(0))
      node tmp37 = gt(tmp36, last-grant17)
      node tmp38 = bit-or(tmp37, tmp30)
      node tmp39 = bit-and(tmp38, out.ready)
      in[0].ready := tmp39
      node tmp40 = bit-and(tmp26, UInt<1>(1))
      node tmp41 = gt(tmp40, last-grant17)
      node tmp42 = bit-or(tmp41, tmp35)
      node tmp43 = bit-and(tmp42, out.ready)
      in[1].ready := tmp43
      accessor a44 = in[chosen]
      out.valid := a44.valid
      accessor a45 = in[chosen]
      out.bits := a45.bits
      wire w46 : UInt<?>
      w46 := UInt<1>(1)
      when in[0].valid :
         w46 := UInt<1>(0)      
      node tmp47 = bit-and(in[1].valid, UInt<1>(1))
      node tmp48 = gt(tmp47, last-grant17)
      wire w49 : UInt<?>
      w49 := w46
      when tmp48 :
         w49 := UInt<1>(1)      
      chosen := w49
      node tmp50 = bit-and(out.ready, out.valid)
      when tmp50 :
         last-grant17 := chosen   
   module SumTop :
      input sreq : {valid : UInt<1>, bits : {v : UInt<32>, len : UInt<32>}, flip ready : UInt<1>}
      output srsp : {valid : UInt<1>, bits : {data : UInt<32>}, flip ready : UInt<1>}
      input mreq : {valid : UInt<1>, bits : {wr? : UInt<1>, tag : UInt<8>, addr : UInt<32>, data : UInt<32>}, flip ready : UInt<1>}
      output mrsp : {valid : UInt<1>, bits : {tag : UInt<8>, data : UInt<32>}, flip ready : UInt<1>}
      inst sum1 of Sum
      inst mem12 of Memory
      inst mreqs16 of ArbiterRR
      mreqs16.in[0] := mreq
      mreqs16.in[1] := sum1.mreq
      mem12.req := mreqs16.out
      sum1.mrsp := mem12.rsp
      mrsp := mem12.rsp
      srsp := sum1.srsp
      sum1.sreq := sreq