HDLRuby 2.2.13 → 2.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/HDLRuby/hdr_samples/memory_test.rb +272 -0
- data/lib/HDLRuby/std/channel.rb +42 -13
- data/lib/HDLRuby/std/memory.rb +163 -19
- data/lib/HDLRuby/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6a6e334b6e55bdc8f7947f92f4dd8a9de83fc0f90725bad5bfafedc27a8ca2e
|
4
|
+
data.tar.gz: a6f43c383176d02af9e8491c6b2425b5e1e8ca3c339464842dbf288fbe91dc26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50a46ad334407428425912ec7b1fbd745d1de686e8792548524f23d4ca10f6252368b589f5fc77b201b07f1becf86aa7c234c77443b1014caad341c1fa0fa966
|
7
|
+
data.tar.gz: c8defb6937e32d43ddd0c56f49a2a608a8444a8ca0eef10f387fb1fc89597dc13871ce086223e8d1892799d1518d9a5cf915142e500cf4c74937bdfbfff68514
|
@@ -0,0 +1,272 @@
|
|
1
|
+
require 'std/memory.rb'
|
2
|
+
|
3
|
+
include HDLRuby::High::Std
|
4
|
+
|
5
|
+
|
6
|
+
# Sample code for testing the memory library.
|
7
|
+
|
8
|
+
system :memory_test do
|
9
|
+
|
10
|
+
# The test step counter.
|
11
|
+
[8].inner :step
|
12
|
+
# The success counter.
|
13
|
+
[4].inner :yay
|
14
|
+
|
15
|
+
# The clock and reset.
|
16
|
+
inner :clk, :rst
|
17
|
+
|
18
|
+
# The memory address.
|
19
|
+
[3].inner :address
|
20
|
+
# The value to write to memories.
|
21
|
+
[8].inner :value
|
22
|
+
# The general result register.
|
23
|
+
[8].inner :result
|
24
|
+
# The specific result registers.
|
25
|
+
[8].inner :res0, :res1, :res2, :res3, :res4, :res5, :res6, :res7
|
26
|
+
|
27
|
+
# Declares a one-ports synchronous memory.
|
28
|
+
mem_sync(1,[8],8,clk.negedge,rst,[:rst]).(:mem_sync_1I)
|
29
|
+
# And the corresponding access ports.
|
30
|
+
mem_sync_1I.branch(0).inner :mem_sync_1P
|
31
|
+
|
32
|
+
# Declares a dual-edge memory for address-based accesses.
|
33
|
+
mem_dual([8],8,clk,rst,raddr: :rst, waddr: :rst).(:mem_dual0I)
|
34
|
+
# And the corresponding access ports.
|
35
|
+
mem_dual0I.branch(:raddr).inner :mem_dual_raddrP
|
36
|
+
mem_dual0I.branch(:waddr).inner :mem_dual_waddrP
|
37
|
+
|
38
|
+
# Declares a second dual-edge memory for incremeted accesses.
|
39
|
+
mem_dual([8],8,clk,rst, rinc: :rst, winc: :rst).(:mem_dual1I)
|
40
|
+
# And the corresponding access ports.
|
41
|
+
mem_dual1I.branch(:rinc).inner :mem_dual_rincP
|
42
|
+
mem_dual1I.branch(:winc).inner :mem_dual_wincP
|
43
|
+
|
44
|
+
# Declares a thrid dual-edge memory for decremented accesses.
|
45
|
+
mem_dual([8],8,clk,rst, rdec: :rst, wdec: :rst).(:mem_dual2I)
|
46
|
+
# And the corresponding access ports.
|
47
|
+
mem_dual2I.branch(:rdec).inner :mem_dual_rdecP
|
48
|
+
mem_dual2I.branch(:wdec).inner :mem_dual_wdecP
|
49
|
+
|
50
|
+
# Declares a first register file for address-based accesses.
|
51
|
+
mem_file([8],8,clk,rst,raddr: :rst, waddr: :rst).(:mem_file0I)
|
52
|
+
# And the corresponding access ports.
|
53
|
+
mem_file0I.branch(:raddr).inner :mem_file_raddrP
|
54
|
+
mem_file0I.branch(:waddr).inner :mem_file_waddrP
|
55
|
+
|
56
|
+
# Declares a second register file for incremeted accesses.
|
57
|
+
mem_file([8],8,clk,rst, rinc: :rst, winc: :rst).(:mem_file1I)
|
58
|
+
# And the corresponding access ports.
|
59
|
+
mem_file1I.branch(:rinc).inner :mem_file_rincP
|
60
|
+
mem_file1I.branch(:winc).inner :mem_file_wincP
|
61
|
+
|
62
|
+
# Declares a third register file for decremeted accesses.
|
63
|
+
mem_file([8],8,clk,rst, rdec: :rst, wdec: :rst).(:mem_file2I)
|
64
|
+
# And the corresponding access ports.
|
65
|
+
mem_file2I.branch(:rdec).inner :mem_file_rdecP
|
66
|
+
mem_file2I.branch(:wdec).inner :mem_file_wdecP
|
67
|
+
|
68
|
+
# Declares a forth register file for num accesses.
|
69
|
+
mem_file([8],8,clk,rst, anum: :rst).(:mem_file3I)
|
70
|
+
# And the corresponding access port.
|
71
|
+
mem_file3I.branch(:anum).inner :mem_file_anumP
|
72
|
+
|
73
|
+
# Declares a fifth register file for num accesses.
|
74
|
+
mem_file([8],8,clk,rst, anum: :rst).(:mem_file4I)
|
75
|
+
# And the corresponding access port: individual accesses.
|
76
|
+
mem_file4I.branch(:anum).inner :mem_file_anum1P
|
77
|
+
mem_file_fixP = [ mem_file_anum1P.wrap(0), mem_file_anum1P.wrap(1),
|
78
|
+
mem_file_anum1P.wrap(2), mem_file_anum1P.wrap(3),
|
79
|
+
mem_file_anum1P.wrap(4), mem_file_anum1P.wrap(5),
|
80
|
+
mem_file_anum1P.wrap(6), mem_file_anum1P.wrap(7) ]
|
81
|
+
|
82
|
+
|
83
|
+
# Tests the accesses to the memories.
|
84
|
+
par(clk.posedge) do
|
85
|
+
# Initial address and value.
|
86
|
+
hif(rst) { address <= 0; value <= 0 }
|
87
|
+
|
88
|
+
# Handles the memory accesses.
|
89
|
+
hcase(step)
|
90
|
+
# Write to mem_sync_1
|
91
|
+
hwhen(1) do
|
92
|
+
mem_sync_1P.write(address,value) do
|
93
|
+
yay <= yay + 1
|
94
|
+
address <= address + 1
|
95
|
+
value <= value + 1
|
96
|
+
end
|
97
|
+
end
|
98
|
+
# Read from to mem_sync_1
|
99
|
+
hwhen(2) do
|
100
|
+
mem_sync_1P.read(address,result) do
|
101
|
+
yay <= yay + 1
|
102
|
+
address <= address + 1
|
103
|
+
end
|
104
|
+
end
|
105
|
+
# Write to mem_dual0 with address
|
106
|
+
hwhen(3) do
|
107
|
+
mem_dual_waddrP.write(address,value) do
|
108
|
+
yay <= yay + 1
|
109
|
+
address <= address + 1
|
110
|
+
value <= value + 1
|
111
|
+
end
|
112
|
+
end
|
113
|
+
# Read from mem_dual0 with address
|
114
|
+
hwhen(4) do
|
115
|
+
mem_dual_raddrP.read(address,result) do
|
116
|
+
yay <= yay + 1
|
117
|
+
address <= address + 1
|
118
|
+
end
|
119
|
+
end
|
120
|
+
# Write to mem_dual1 with increment
|
121
|
+
hwhen(5) do
|
122
|
+
mem_dual_wincP.write(value) do
|
123
|
+
yay <= yay + 1
|
124
|
+
value <= value + 1
|
125
|
+
end
|
126
|
+
end
|
127
|
+
# Read from mem_dual1 with increment
|
128
|
+
hwhen(6) do
|
129
|
+
mem_dual_rincP.read(result) do
|
130
|
+
yay <= yay + 1
|
131
|
+
end
|
132
|
+
end
|
133
|
+
# Write to mem_dual2 with decrement
|
134
|
+
hwhen(7) do
|
135
|
+
mem_dual_wdecP.write(value) do
|
136
|
+
yay <= yay + 1
|
137
|
+
value <= value + 1
|
138
|
+
end
|
139
|
+
end
|
140
|
+
# Read from mem_dual1 with decrement
|
141
|
+
hwhen(8) do
|
142
|
+
mem_dual_rdecP.read(result) do
|
143
|
+
yay <= yay + 1
|
144
|
+
end
|
145
|
+
end
|
146
|
+
# Write to mem_file0 with address
|
147
|
+
hwhen(9) do
|
148
|
+
mem_file_waddrP.write(address,value) do
|
149
|
+
yay <= yay + 1
|
150
|
+
address <= address + 1
|
151
|
+
value <= value + 1
|
152
|
+
end
|
153
|
+
end
|
154
|
+
# Read from mem_file0 with address
|
155
|
+
hwhen(10) do
|
156
|
+
mem_file_raddrP.read(address,result) do
|
157
|
+
yay <= yay + 1
|
158
|
+
address <= address + 1
|
159
|
+
end
|
160
|
+
end
|
161
|
+
# Write to mem_file1 with increment
|
162
|
+
hwhen(11) do
|
163
|
+
mem_file_wincP.write(value) do
|
164
|
+
yay <= yay + 1
|
165
|
+
value <= value + 1
|
166
|
+
end
|
167
|
+
end
|
168
|
+
# Read from mem_file1 with increment
|
169
|
+
hwhen(12) do
|
170
|
+
mem_file_rincP.read(result) do
|
171
|
+
yay <= yay + 1
|
172
|
+
end
|
173
|
+
end
|
174
|
+
# Write to mem_file2 with increment
|
175
|
+
hwhen(13) do
|
176
|
+
mem_file_wdecP.write(value) do
|
177
|
+
yay <= yay + 1
|
178
|
+
value <= value + 1
|
179
|
+
end
|
180
|
+
end
|
181
|
+
# Read from mem_file2 with increment
|
182
|
+
hwhen(14) do
|
183
|
+
mem_file_rdecP.read(result) do
|
184
|
+
yay <= yay + 1
|
185
|
+
end
|
186
|
+
end
|
187
|
+
# Write to mem_file3 with num access
|
188
|
+
hwhen(15) do
|
189
|
+
mem_file_anumP.write(0,0)
|
190
|
+
mem_file_anumP.write(1,1)
|
191
|
+
mem_file_anumP.write(2,2)
|
192
|
+
mem_file_anumP.write(3,3)
|
193
|
+
mem_file_anumP.write(4,4)
|
194
|
+
mem_file_anumP.write(5,5)
|
195
|
+
mem_file_anumP.write(6,6)
|
196
|
+
mem_file_anumP.write(7,7) do
|
197
|
+
yay <= 8
|
198
|
+
end
|
199
|
+
end
|
200
|
+
# Read from mem_file3 with num access
|
201
|
+
hwhen(16) do
|
202
|
+
mem_file_anumP.read(0,res0)
|
203
|
+
mem_file_anumP.read(1,res1)
|
204
|
+
mem_file_anumP.read(2,res2)
|
205
|
+
mem_file_anumP.read(3,res3)
|
206
|
+
mem_file_anumP.read(4,res4)
|
207
|
+
mem_file_anumP.read(5,res5)
|
208
|
+
mem_file_anumP.read(6,res6)
|
209
|
+
mem_file_anumP.read(7,res7) do
|
210
|
+
yay <= 8
|
211
|
+
end
|
212
|
+
end
|
213
|
+
# Write to mem_file3 with num access
|
214
|
+
hwhen(17) do
|
215
|
+
mem_file_fixP[0].write(1)
|
216
|
+
mem_file_fixP[1].write(2)
|
217
|
+
mem_file_fixP[2].write(4)
|
218
|
+
mem_file_fixP[3].write(8)
|
219
|
+
mem_file_fixP[4].write(16)
|
220
|
+
mem_file_fixP[5].write(32)
|
221
|
+
mem_file_fixP[6].write(64)
|
222
|
+
mem_file_fixP[7].write(128) do
|
223
|
+
yay <= 8
|
224
|
+
end
|
225
|
+
end
|
226
|
+
# Read from mem_file3 with num access
|
227
|
+
hwhen(18) do
|
228
|
+
mem_file_fixP[0].read(res0)
|
229
|
+
mem_file_fixP[1].read(res1)
|
230
|
+
mem_file_fixP[2].read(res2)
|
231
|
+
mem_file_fixP[3].read(res3)
|
232
|
+
mem_file_fixP[4].read(res4)
|
233
|
+
mem_file_fixP[5].read(res5)
|
234
|
+
mem_file_fixP[6].read(res6)
|
235
|
+
mem_file_fixP[7].read(res7) do
|
236
|
+
yay <= 8
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
|
242
|
+
timed do
|
243
|
+
# Initialize everything.
|
244
|
+
clk <= 0
|
245
|
+
rst <= 0
|
246
|
+
step <= 0
|
247
|
+
yay <= 0
|
248
|
+
!10.ns
|
249
|
+
clk <= 1
|
250
|
+
!10.ns
|
251
|
+
clk <= 0
|
252
|
+
rst <= 1
|
253
|
+
!10.ns
|
254
|
+
clk <= 1
|
255
|
+
!10.ns
|
256
|
+
clk <= 0
|
257
|
+
rst <= 0
|
258
|
+
step <= 1
|
259
|
+
|
260
|
+
# Testing the synchronous memories.
|
261
|
+
256.times do
|
262
|
+
!10.ns
|
263
|
+
clk <= 1
|
264
|
+
!10.ns
|
265
|
+
hif(yay==8) do
|
266
|
+
step <= step + 1
|
267
|
+
yay <= 0
|
268
|
+
end
|
269
|
+
clk <= 0
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
data/lib/HDLRuby/std/channel.rb
CHANGED
@@ -82,10 +82,10 @@ module HDLRuby::High::Std
|
|
82
82
|
|
83
83
|
|
84
84
|
##
|
85
|
-
# Module for
|
86
|
-
module
|
87
|
-
#
|
88
|
-
def
|
85
|
+
# Module for wrapping channel ports.
|
86
|
+
module ChannelPortWrapping
|
87
|
+
# Wrap with +args+ arguments.
|
88
|
+
def wrap(*args)
|
89
89
|
return ChannelPortB.new(self,*args)
|
90
90
|
end
|
91
91
|
end
|
@@ -94,7 +94,7 @@ module HDLRuby::High::Std
|
|
94
94
|
##
|
95
95
|
# Describes a read port to a channel.
|
96
96
|
class ChannelPortR
|
97
|
-
include
|
97
|
+
include ChannelPortWrapping
|
98
98
|
|
99
99
|
# Creates a new channel reader running in +namespace+ and
|
100
100
|
# reading using +reader_proc+ and reseting using +reseter_proc+.
|
@@ -138,7 +138,7 @@ module HDLRuby::High::Std
|
|
138
138
|
##
|
139
139
|
# Describes a writer port to a channel.
|
140
140
|
class ChannelPortW
|
141
|
-
include
|
141
|
+
include ChannelPortWrapping
|
142
142
|
|
143
143
|
# Creates a new channel writer running in +namespace+ and
|
144
144
|
# writing using +writer_proc+ and reseting using +reseter_proc+.
|
@@ -182,7 +182,7 @@ module HDLRuby::High::Std
|
|
182
182
|
##
|
183
183
|
# Describes an access port to a channel.
|
184
184
|
class ChannelPortA
|
185
|
-
include
|
185
|
+
include ChannelPortWrapping
|
186
186
|
|
187
187
|
# Creates a new channel accesser running in +namespace+
|
188
188
|
# and reading using +reader_proc+, writing using +writer_proc+,
|
@@ -242,32 +242,61 @@ module HDLRuby::High::Std
|
|
242
242
|
|
243
243
|
|
244
244
|
##
|
245
|
-
# Describes port
|
245
|
+
# Describes port wrapper (Box) for fixing arugments.
|
246
246
|
class ChannelPortB
|
247
|
-
include
|
247
|
+
include ChannelPortWrapping
|
248
248
|
|
249
249
|
# Creates a new channel box over channel port +port+ fixing +args+
|
250
250
|
# as arguments.
|
251
|
+
# +args+ is a list of arguments to apply to all read, write
|
252
|
+
# and access procedure, nil values meaning that the corresponding
|
253
|
+
# argument is not overwritten.
|
254
|
+
# It can also be three lists for seperate read, write and access
|
255
|
+
# procedures using named arguments as:
|
256
|
+
# read: <read arguments>, write: <write arguments>,
|
257
|
+
# access: <access arguments>
|
251
258
|
def initialize(port,*args)
|
252
259
|
# Ensure port is a channel port.
|
253
260
|
unless port.is_a?(ChannelPortR) || port.is_a?(ChannelPortW) ||
|
254
|
-
|
261
|
+
port.is_a?(ChannelPortA) || port.is_a?(ChannelPortB)
|
255
262
|
raise "Invalid class for a channel port: #{port.class}"
|
256
263
|
end
|
257
264
|
@port = port
|
258
|
-
|
265
|
+
# Process the arguments.
|
266
|
+
if args.size == 1 && args[0].is_a?(Hash) then
|
267
|
+
# Read, write and access are separated.
|
268
|
+
@args_read = args[0][:read]
|
269
|
+
@args_write = args[0][:write]
|
270
|
+
@args_access = args[0][:access]
|
271
|
+
else
|
272
|
+
@args_read = args
|
273
|
+
@args_write = args.clone
|
274
|
+
@args_access = args.clone
|
275
|
+
end
|
259
276
|
end
|
260
277
|
|
261
278
|
## Performs a read on the channel using +args+ and +ruby_block+
|
262
279
|
# as arguments.
|
263
280
|
def read(*args,&ruby_block)
|
264
|
-
|
281
|
+
# Generate the final arguments: fills the nil with arguments
|
282
|
+
# from args
|
283
|
+
rargs = @args_read.clone
|
284
|
+
rargs.map! { |arg| arg == nil ? args.shift : arg }
|
285
|
+
# And add the remaining at the tail.
|
286
|
+
rargs += args
|
287
|
+
@port.read(*rargs,&ruby_block)
|
265
288
|
end
|
266
289
|
|
267
290
|
## Performs a write on the channel using +args+ and +ruby_block+
|
268
291
|
# as arguments.
|
269
292
|
def write(*args,&ruby_block)
|
270
|
-
|
293
|
+
# Generate the final arguments: fills the nil with arguments
|
294
|
+
# from args
|
295
|
+
rargs = @args_write.clone
|
296
|
+
rargs.map! { |arg| arg == nil ? args.shift : arg }
|
297
|
+
# And add the remaining at the tail.
|
298
|
+
rargs += args
|
299
|
+
@port.write(*rargs,&ruby_block)
|
271
300
|
end
|
272
301
|
|
273
302
|
## Performs a reset on the channel using +args+ and +ruby_block+
|
data/lib/HDLRuby/std/memory.rb
CHANGED
@@ -243,23 +243,14 @@ HDLRuby::High::Std.channel(:mem_dual) do |typ,size,clk,rst,br_rsts = {}|
|
|
243
243
|
typ.inner :dbus_r, :dbus_w
|
244
244
|
# Address buses (or simply registers)
|
245
245
|
[awidth].inner :abus_r, :abus_w
|
246
|
-
# # Address buffers
|
247
|
-
# [awidth].inner :abus_r_reg
|
248
246
|
|
249
247
|
# Declare the memory content.
|
250
248
|
typ[-size].inner :mem
|
251
249
|
|
252
|
-
#
|
253
|
-
par(clk.posedge) do
|
254
|
-
# # # Output memory value for reading at each cycle.
|
255
|
-
# # dbus_r <= mem[abus_r_reg]
|
256
|
-
# Manage the write to the memory.
|
257
|
-
hif(trig_w) { mem[abus_w] <= dbus_w }
|
258
|
-
end
|
259
|
-
# par(clk.negedge) { abus_r_reg <= abus_r }
|
250
|
+
# Processes handling the memory access.
|
260
251
|
par(clk.negedge) do
|
261
252
|
dbus_r <= mem[abus_r]
|
262
|
-
|
253
|
+
hif(trig_w) { mem[abus_w] <= dbus_w }
|
263
254
|
end
|
264
255
|
|
265
256
|
# The address branches.
|
@@ -403,10 +394,7 @@ HDLRuby::High::Std.channel(:mem_dual) do |typ,size,clk,rst,br_rsts = {}|
|
|
403
394
|
par do
|
404
395
|
hif(rst == 0) do
|
405
396
|
# No reset, so can perform the write.
|
406
|
-
|
407
|
-
# The trigger was previously set, write ok.
|
408
|
-
blk.call
|
409
|
-
end if blk
|
397
|
+
blk.call if blk
|
410
398
|
# Prepare the write.
|
411
399
|
abus_w <= abus_w + 1
|
412
400
|
trig_w <= 1
|
@@ -416,6 +404,84 @@ HDLRuby::High::Std.channel(:mem_dual) do |typ,size,clk,rst,br_rsts = {}|
|
|
416
404
|
end
|
417
405
|
end
|
418
406
|
|
407
|
+
|
408
|
+
# The decrement branches.
|
409
|
+
# Read with increment
|
410
|
+
brancher(:rdec) do
|
411
|
+
reader_output :trig_r, :abus_r
|
412
|
+
reader_input :dbus_r
|
413
|
+
if br_rsts[:rdec] then
|
414
|
+
rst_name = br_rsts[:rdec].to_sym
|
415
|
+
else
|
416
|
+
rst_name = rst.name
|
417
|
+
reader_input rst_name
|
418
|
+
end
|
419
|
+
|
420
|
+
# Defines the read procedure at address +addr+
|
421
|
+
# using +target+ as target of access result.
|
422
|
+
reader do |blk,target|
|
423
|
+
# By default the read trigger is 0.
|
424
|
+
rst = send(rst_name)
|
425
|
+
top_block.unshift do
|
426
|
+
# Initialize the address so that the next access is at address 0.
|
427
|
+
hif(rst==1) { abus_r <= 0 }
|
428
|
+
# Reset so switch of the access trigger.
|
429
|
+
trig_r <= 0
|
430
|
+
end
|
431
|
+
# The read procedure.
|
432
|
+
par do
|
433
|
+
hif(rst == 0) do
|
434
|
+
# No reset, so can perform the read.
|
435
|
+
hif(trig_r == 1) do
|
436
|
+
# The trigger was previously set, read ok.
|
437
|
+
target <= dbus_r
|
438
|
+
blk.call if blk
|
439
|
+
end
|
440
|
+
# Prepare the read.
|
441
|
+
abus_r <= abus_r - 1
|
442
|
+
trig_r <= 1
|
443
|
+
end
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
# Write with address
|
449
|
+
brancher(:wdec) do
|
450
|
+
writer_output :trig_w, :abus_w, :dbus_w
|
451
|
+
if br_rsts[:wdec] then
|
452
|
+
rst_name = br_rsts[:wdec].to_sym
|
453
|
+
else
|
454
|
+
rst_name = rst.name
|
455
|
+
writer_input rst_name
|
456
|
+
end
|
457
|
+
# puts "br_rsts=#{br_rsts}"
|
458
|
+
# puts "rst_name=#{rst_name}"
|
459
|
+
|
460
|
+
# Defines the read procedure at address +addr+
|
461
|
+
# using +target+ as target of access result.
|
462
|
+
writer do |blk,target|
|
463
|
+
# By default the read trigger is 0.
|
464
|
+
rst = send(rst_name)
|
465
|
+
top_block.unshift do
|
466
|
+
# Initialize the address so that the next access is at address 0.
|
467
|
+
hif(rst == 1) { abus_w <= 0 }
|
468
|
+
# Reset so switch of the access trigger.
|
469
|
+
trig_w <= 0
|
470
|
+
end
|
471
|
+
# The write procedure.
|
472
|
+
par do
|
473
|
+
hif(rst == 0) do
|
474
|
+
# No reset, so can perform the write.
|
475
|
+
blk.call if blk
|
476
|
+
# Prepare the write.
|
477
|
+
abus_w <= abus_w - 1
|
478
|
+
trig_w <= 1
|
479
|
+
dbus_w <= target
|
480
|
+
end
|
481
|
+
end
|
482
|
+
end
|
483
|
+
end
|
484
|
+
|
419
485
|
end
|
420
486
|
|
421
487
|
|
@@ -436,8 +502,7 @@ end
|
|
436
502
|
#
|
437
503
|
# * The following branches are possible (only one read and one write can
|
438
504
|
# be used per channel)
|
439
|
-
# -
|
440
|
-
# - wnum: writer by register number, the number must be a defined value.
|
505
|
+
# - anum: access by register number, the number must be a defined value.
|
441
506
|
# - raddr: read by address
|
442
507
|
# - waddr: read by address
|
443
508
|
# - rinc: read by automatically incremented address.
|
@@ -536,7 +601,6 @@ HDLRuby::High::Std.channel(:mem_file) do |typ,size,clk,rst,br_rsts = {}|
|
|
536
601
|
# Read with address
|
537
602
|
brancher(:raddr) do
|
538
603
|
size.times { |i| reader_input :"reg_#{i}" }
|
539
|
-
regs = size.times.map {|i| send(:"reg_#{i}") }
|
540
604
|
if br_rsts[:raddr] then
|
541
605
|
rst_name = br_rsts[:raddr].to_sym
|
542
606
|
else
|
@@ -547,6 +611,7 @@ HDLRuby::High::Std.channel(:mem_file) do |typ,size,clk,rst,br_rsts = {}|
|
|
547
611
|
# Defines the read procedure at address +addr+
|
548
612
|
# using +target+ as target of access result.
|
549
613
|
reader do |blk,addr,target|
|
614
|
+
regs = size.times.map {|i| send(:"reg_#{i}") }
|
550
615
|
# The read procedure.
|
551
616
|
rst = send(rst_name)
|
552
617
|
par do
|
@@ -565,7 +630,6 @@ HDLRuby::High::Std.channel(:mem_file) do |typ,size,clk,rst,br_rsts = {}|
|
|
565
630
|
# Write with address
|
566
631
|
brancher(:waddr) do
|
567
632
|
size.times { |i| writer_output :"reg_#{i}" }
|
568
|
-
regs = size.times.map {|i| send(:"reg_#{i}") }
|
569
633
|
if br_rsts[:waddr] then
|
570
634
|
rst_name = br_rsts[:waddr].to_sym
|
571
635
|
else
|
@@ -576,6 +640,7 @@ HDLRuby::High::Std.channel(:mem_file) do |typ,size,clk,rst,br_rsts = {}|
|
|
576
640
|
# Defines the writer procedure at address +addr+
|
577
641
|
# using +target+ as target of access.
|
578
642
|
writer do |blk,addr,target|
|
643
|
+
regs = size.times.map {|i| send(:"reg_#{i}") }
|
579
644
|
# The writer procedure.
|
580
645
|
rst = send(rst_name)
|
581
646
|
par do
|
@@ -672,4 +737,83 @@ HDLRuby::High::Std.channel(:mem_file) do |typ,size,clk,rst,br_rsts = {}|
|
|
672
737
|
end
|
673
738
|
|
674
739
|
|
740
|
+
# The decrement branches.
|
741
|
+
# Read with decrement
|
742
|
+
brancher(:rdec) do
|
743
|
+
size.times { |i| reader_input :"reg_#{i}" }
|
744
|
+
if br_rsts[:rdec] then
|
745
|
+
rst_name = br_rsts[:rdec].to_sym
|
746
|
+
else
|
747
|
+
rst_name = rst.name
|
748
|
+
reader_input rst_name
|
749
|
+
end
|
750
|
+
# Declares the address counter.
|
751
|
+
[size.width-1].inner :abus_r
|
752
|
+
reader_inout :abus_r
|
753
|
+
|
754
|
+
# Defines the read procedure at address +addr+
|
755
|
+
# using +target+ as target of access result.
|
756
|
+
reader do |blk,target|
|
757
|
+
regs = size.times.map {|i| send(:"reg_#{i}") }
|
758
|
+
# By default the read trigger is 0.
|
759
|
+
rst = send(rst_name)
|
760
|
+
top_block.unshift do
|
761
|
+
# Initialize the address so that the next access is at address 0.
|
762
|
+
hif(rst==1) { abus_r <= -1 }
|
763
|
+
end
|
764
|
+
# The read procedure.
|
765
|
+
par do
|
766
|
+
hif(rst == 0) do
|
767
|
+
# No reset, so can perform the read.
|
768
|
+
hcase(abus_r)
|
769
|
+
size.times do |i|
|
770
|
+
hwhen(i) { target <= regs[i] }
|
771
|
+
end
|
772
|
+
blk.call if blk
|
773
|
+
# Prepare the next read.
|
774
|
+
abus_r <= abus_r - 1
|
775
|
+
end
|
776
|
+
end
|
777
|
+
end
|
778
|
+
end
|
779
|
+
|
780
|
+
# Write with decrement
|
781
|
+
brancher(:wdec) do
|
782
|
+
size.times { |i| writer_output :"reg_#{i}" }
|
783
|
+
if br_rsts[:wdec] then
|
784
|
+
rst_name = br_rsts[:wdec].to_sym
|
785
|
+
else
|
786
|
+
rst_name = rst.name
|
787
|
+
reader_input rst_name
|
788
|
+
end
|
789
|
+
# Declares the address counter.
|
790
|
+
[size.width-1].inner :abus_w
|
791
|
+
reader_inout :abus_w
|
792
|
+
|
793
|
+
# Defines the write procedure at address +addr+
|
794
|
+
# using +target+ as target of access result.
|
795
|
+
writer do |blk,target|
|
796
|
+
regs = size.times.map {|i| send(:"reg_#{i}") }
|
797
|
+
# By default the read trigger is 0.
|
798
|
+
rst = send(rst_name)
|
799
|
+
top_block.unshift do
|
800
|
+
# Initialize the address so that the next access is at address 0.
|
801
|
+
hif(rst==1) { abus_w <= -1 }
|
802
|
+
end
|
803
|
+
# The read procedure.
|
804
|
+
par do
|
805
|
+
hif(rst == 0) do
|
806
|
+
# No reset, so can perform the read.
|
807
|
+
hcase(abus_w)
|
808
|
+
size.times do |i|
|
809
|
+
hwhen(i) { regs[i] <= target }
|
810
|
+
end
|
811
|
+
blk.call if blk
|
812
|
+
# Prepare the next write.
|
813
|
+
abus_w <= abus_w - 1
|
814
|
+
end
|
815
|
+
end
|
816
|
+
end
|
817
|
+
end
|
818
|
+
|
675
819
|
end
|
data/lib/HDLRuby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: HDLRuby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lovic Gauthier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/HDLRuby/hdr_samples/instance_open.rb
|
85
85
|
- lib/HDLRuby/hdr_samples/mei8.rb
|
86
86
|
- lib/HDLRuby/hdr_samples/mei8_bench.rb
|
87
|
+
- lib/HDLRuby/hdr_samples/memory_test.rb
|
87
88
|
- lib/HDLRuby/hdr_samples/multer_gen.rb
|
88
89
|
- lib/HDLRuby/hdr_samples/multer_seq.rb
|
89
90
|
- lib/HDLRuby/hdr_samples/neural/a.rb
|