HDLRuby 2.4.27 → 2.4.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/HDLRuby/hdr_samples/seqpar_bench.rb +59 -0
- data/lib/HDLRuby/hdrcc.rb +2 -0
- data/lib/HDLRuby/hruby_low_without_parinseq.rb +151 -0
- data/lib/HDLRuby/hruby_verilog.rb +236 -131
- data/lib/HDLRuby/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad6c03f726ed838a4d5456f41c4b0f295e4ca7d10ca8585ee8f8c011f7f2fd23
|
4
|
+
data.tar.gz: a59727e177be4d5ff3eb740d210fad37bd4ba9ea6296a8cfed84495a7122411d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc19bcb5b44267c6506a9a1b3547d516b565a2a3ea997bf2ab5cada119caafb0fee09220c7da2e92321562ed2588dc5b6c58c6c697d3230daa8942c00fb731f6
|
7
|
+
data.tar.gz: c6849492302732600fe232d73f6984c4fe1a94e4d818349d5400fb15979eecc6b2b32d71a81b50f09713c5143236e13f330f763ea98beeda4a939d77b8d2fba9
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# require "../hruby_low2c.rb"
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
# A system for testing the execution of par block in seq block.
|
6
|
+
system :seqpar_bench do
|
7
|
+
|
8
|
+
inner :rst, :clk
|
9
|
+
signed[8].inner :a, :b, :c, :d
|
10
|
+
signed[8].inner :out
|
11
|
+
|
12
|
+
seq(clk.posedge) do
|
13
|
+
hif(rst) do
|
14
|
+
a <= 0
|
15
|
+
b <= 0
|
16
|
+
c <= 0
|
17
|
+
d <= 0
|
18
|
+
end
|
19
|
+
helse do
|
20
|
+
a <= a + 1
|
21
|
+
b <= a + 2
|
22
|
+
par do
|
23
|
+
c <= b + 3
|
24
|
+
d <= c + 4
|
25
|
+
end
|
26
|
+
a <= d + 5
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
out <= a
|
31
|
+
|
32
|
+
timed do
|
33
|
+
clk <= 0
|
34
|
+
rst <= 0
|
35
|
+
!20.ns
|
36
|
+
clk <= 1
|
37
|
+
!20.ns
|
38
|
+
clk <= 0
|
39
|
+
rst <= 1
|
40
|
+
!20.ns
|
41
|
+
clk <= 1
|
42
|
+
!20.ns
|
43
|
+
clk <= 0
|
44
|
+
rst <= 0
|
45
|
+
!20.ns
|
46
|
+
clk <= 1
|
47
|
+
!20.ns
|
48
|
+
clk <= 0
|
49
|
+
!20.ns
|
50
|
+
clk <= 1
|
51
|
+
!20.ns
|
52
|
+
clk <= 0
|
53
|
+
!20.ns
|
54
|
+
clk <= 1
|
55
|
+
!20.ns
|
56
|
+
clk <= 0
|
57
|
+
!20.ns
|
58
|
+
end
|
59
|
+
end
|
data/lib/HDLRuby/hdrcc.rb
CHANGED
@@ -20,6 +20,7 @@ require 'HDLRuby/hruby_low_with_var'
|
|
20
20
|
require 'HDLRuby/hruby_low_without_concat'
|
21
21
|
require 'HDLRuby/hruby_low_without_connection'
|
22
22
|
require 'HDLRuby/hruby_low_casts_without_expression'
|
23
|
+
require 'hruby_low_without_parinseq'
|
23
24
|
require 'HDLRuby/hruby_low_cleanup'
|
24
25
|
|
25
26
|
require 'HDLRuby/hruby_verilog.rb'
|
@@ -583,6 +584,7 @@ elsif $options[:verilog] then
|
|
583
584
|
systemT.to_global_systemTs!
|
584
585
|
# systemT.break_types!
|
585
586
|
# systemT.expand_types!
|
587
|
+
systemT.par_in_seq2seq!
|
586
588
|
systemT.initial_concat_to_timed!
|
587
589
|
systemT.with_port!
|
588
590
|
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'HDLRuby'
|
2
|
+
require 'HDLRuby/hruby_tools'
|
3
|
+
require 'HDLRuby/hruby_low_mutable'
|
4
|
+
|
5
|
+
|
6
|
+
module HDLRuby::Low
|
7
|
+
|
8
|
+
|
9
|
+
##
|
10
|
+
# Converts par blocks within seq blocks to seq blocks.
|
11
|
+
# For matching the executing model of Verilog.
|
12
|
+
#
|
13
|
+
########################################################################
|
14
|
+
|
15
|
+
|
16
|
+
## Extends the SystemT class with functionality for converting par blocks
|
17
|
+
# within seq blocks to seq blocks.
|
18
|
+
class SystemT
|
19
|
+
|
20
|
+
# Converts par blocks within seq blocks to seq blocks.
|
21
|
+
def par_in_seq2seq!
|
22
|
+
self.scope.par_in_seq2seq!
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
## Extends the Scope class with functionality for breaking assingments
|
27
|
+
# to concats.
|
28
|
+
class Scope
|
29
|
+
# Converts par blocks within seq blocks to seq blocks.
|
30
|
+
def par_in_seq2seq!
|
31
|
+
# Recruse on the sub scopes.
|
32
|
+
self.each_scope(&:par_in_seq2seq!)
|
33
|
+
# Recurse on the block.
|
34
|
+
self.each_behavior do |behavior|
|
35
|
+
behavior.block.par_in_seq2seq!
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
## Extends the Statement class with functionality for breaking assingments
|
42
|
+
# to concats.
|
43
|
+
class Statement
|
44
|
+
# Converts par blocks within seq blocks to seq blocks.
|
45
|
+
def par_in_seq2seq!
|
46
|
+
# By default nothing to do.
|
47
|
+
return self
|
48
|
+
end
|
49
|
+
|
50
|
+
# Convert the block to seq.
|
51
|
+
def to_seq!
|
52
|
+
# By default nothing to do.
|
53
|
+
return self
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
## Extends the If class with functionality for breaking assingments
|
59
|
+
# to concats.
|
60
|
+
class If
|
61
|
+
# Converts par blocks within seq blocks to seq blocks.
|
62
|
+
def par_in_seq2seq!
|
63
|
+
self.yes.par_in_seq2seq!
|
64
|
+
self.each_noif do |cond,blk|
|
65
|
+
blk.par_in_seq2seq!
|
66
|
+
end
|
67
|
+
self.no.par_in_seq2seq! if self.no
|
68
|
+
end
|
69
|
+
|
70
|
+
# Convert the block to seq.
|
71
|
+
def to_seq!
|
72
|
+
self.to_seq!
|
73
|
+
self.each_noif do |cond,blk|
|
74
|
+
blk.to_seq!
|
75
|
+
end
|
76
|
+
self.no.to_seq! if self.no
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
## Extends the Case class with functionality for breaking assingments
|
82
|
+
# to concats.
|
83
|
+
class Case
|
84
|
+
# Converts par blocks within seq blocks to seq blocks.
|
85
|
+
def par_in_seq2seq!
|
86
|
+
self.each_when do |w|
|
87
|
+
w.statement.par_in_seq2seq!
|
88
|
+
end
|
89
|
+
self.default.par_in_seq2seq! if self.default
|
90
|
+
end
|
91
|
+
|
92
|
+
# Convert the block to seq.
|
93
|
+
def to_seq!
|
94
|
+
self.each_when do |w|
|
95
|
+
w.statement.to_seq!
|
96
|
+
end
|
97
|
+
self.default.to_seq! if self.default
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
## Extends the Block class with functionality for breaking assingments
|
103
|
+
# to concats.
|
104
|
+
class Block
|
105
|
+
# Converts par blocks within seq blocks to seq blocks.
|
106
|
+
def par_in_seq2seq!
|
107
|
+
# Recurse on the sub blocks.
|
108
|
+
self.each_statement(&:par_in_seq2seq!)
|
109
|
+
# Is the current block a seq block?
|
110
|
+
if self.mode == :seq then
|
111
|
+
# Yes, convert its inner par blocks to seq blocks.
|
112
|
+
self.each_statement do |statement|
|
113
|
+
if (statement.is_a?(Block)) then
|
114
|
+
statement.to_seq! if statement.mode == :par
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
return self
|
119
|
+
end
|
120
|
+
|
121
|
+
# Convert the block to seq.
|
122
|
+
def to_seq!
|
123
|
+
if self.mode == :par then
|
124
|
+
# Need to convert.
|
125
|
+
# First recurse on the sub blocks.
|
126
|
+
self.each_statement(&:to_seq!)
|
127
|
+
# Now replace each left value by a new signal for
|
128
|
+
# differed assingment in seq.
|
129
|
+
differeds = []
|
130
|
+
self.each_statement do |statement|
|
131
|
+
left = statement.left
|
132
|
+
if statement.is_a?(Transmit) then
|
133
|
+
sig = SignalI.new(HDLRuby.uniq_name,left.type)
|
134
|
+
self.add_inner(sig)
|
135
|
+
diff = RefName.new(left.type,RefThis.new,sig.name)
|
136
|
+
differeds << [left,diff]
|
137
|
+
statement.set_left!(diff)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
# Adds the differed assignments.
|
141
|
+
differeds.each do |left,diff|
|
142
|
+
self.add_statement(Transmit.new(left.clone,diff.clone))
|
143
|
+
end
|
144
|
+
# Change the mode.
|
145
|
+
self.set_mode!(:seq)
|
146
|
+
end
|
147
|
+
return self
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
@@ -14,6 +14,9 @@ module HDLRuby::Low
|
|
14
14
|
# The list of base types used both in verilog and HDLRuby
|
15
15
|
VERILOG_BASE_TYPES = ["signed"]
|
16
16
|
|
17
|
+
# The list of signals that are actually verilog regs.
|
18
|
+
VERILOG_REGS = []
|
19
|
+
|
17
20
|
|
18
21
|
# Sample of very handy for programming.
|
19
22
|
# puts "class=#{self.yes.class}" # Confirm class of self.yes.
|
@@ -25,7 +28,7 @@ module HDLRuby::Low
|
|
25
28
|
# end
|
26
29
|
|
27
30
|
# Global variable used for indentation and structure (temporary).
|
28
|
-
$space_count = 0 # Count used for increasing indent by if statement. (temporary)
|
31
|
+
# $space_count = 0 # Count used for increasing indent by if statement. (temporary)
|
29
32
|
$vector_reg = "" # For storing signal type at structure declaration. (temporary)
|
30
33
|
$vector_cnt = 0 # For allocating numbers at structure declaration. (temporary)
|
31
34
|
|
@@ -101,9 +104,11 @@ end
|
|
101
104
|
# Enhance Transmit with generation of verilog code.
|
102
105
|
class Transmit
|
103
106
|
# Converts the system to Verilog code.
|
104
|
-
def to_verilog(mode = nil)
|
107
|
+
# def to_verilog(mode = nil)
|
108
|
+
def to_verilog(spc = 3)
|
105
109
|
# Determine blocking assignment or nonblocking substitution from mode and return it.
|
106
|
-
code = "#{self.left.to_verilog} #{mode == "seq" ? "=" : "<="} #{self.right.to_verilog};\n"
|
110
|
+
# code = "#{self.left.to_verilog} #{mode == "seq" ? "=" : "<="} #{self.right.to_verilog};\n"
|
111
|
+
code = "#{" " * spc}#{self.left.to_verilog} #{self.block.mode == :seq ? "=" : "<="} #{self.right.to_verilog};"
|
107
112
|
return code
|
108
113
|
end
|
109
114
|
end
|
@@ -111,12 +116,68 @@ end
|
|
111
116
|
# To scheduling to the Block.
|
112
117
|
# Enhance Block with generation of verilog code.
|
113
118
|
class Block
|
114
|
-
# Converts the system to Verilog code.
|
115
|
-
def to_verilog(mode = nil)
|
116
|
-
|
117
|
-
|
119
|
+
# # Converts the system to Verilog code.
|
120
|
+
# def to_verilog(mode = nil)
|
121
|
+
# # No translation is done in this class.
|
122
|
+
# puts "Block to_verilog not found" # For debugging
|
123
|
+
# end
|
124
|
+
|
125
|
+
# Converts the system to Verilog code adding 'spc' spaces at the begining
|
126
|
+
# of each line.
|
127
|
+
def to_verilog(spc = 3)
|
128
|
+
code = "begin"
|
129
|
+
code << " : #{name_to_verilog(self.name)}" if self.name && !self.name.empty?
|
130
|
+
code << "\n" if block.each_inner.any?
|
131
|
+
# Declaration of "inner" part within "always".
|
132
|
+
block.each_inner do |inner|
|
133
|
+
# if regs.include?(inner.name) then
|
134
|
+
if HDLRuby::Low::VERILOG_REGS.include?(inner.to_verilog) then
|
135
|
+
# code << " reg"
|
136
|
+
code << "#{" " * (spc+3)}reg"
|
137
|
+
else
|
138
|
+
code << "#{" " * (spc+3)}wire"
|
139
|
+
end
|
140
|
+
|
141
|
+
# Variable has "base", but if there is width etc, it is not in "base".
|
142
|
+
# It is determined by an if.
|
143
|
+
if inner.type.base?
|
144
|
+
if inner.type.base.base?
|
145
|
+
# code << "#{inner.type.base.to_verilog} #{inner.to_verilog} #{inner.type.to_verilog};\n"
|
146
|
+
code << "#{inner.type.base.to_verilog} #{inner.to_verilog} #{inner.type.to_verilog}"
|
147
|
+
else
|
148
|
+
# code << "#{inner.type.to_verilog} #{inner.to_verilog};\n"
|
149
|
+
code << "#{inner.type.to_verilog} #{inner.to_verilog}"
|
150
|
+
end
|
151
|
+
else
|
152
|
+
# code << " #{inner.type.to_verilog}#{inner.to_verilog};\n"
|
153
|
+
code << " #{inner.type.to_verilog}#{inner.to_verilog}"
|
154
|
+
end
|
155
|
+
if inner.value then
|
156
|
+
# There is an initial value.
|
157
|
+
code << " = #{inner.value.to_verilog}"
|
158
|
+
end
|
159
|
+
code << ";\n"
|
160
|
+
end
|
161
|
+
|
162
|
+
# Translate the block that finished scheduling.
|
163
|
+
block.each_statement do |statement|
|
164
|
+
#code << "\n #{statement.to_verilog(behavior.block.mode.to_s)}"
|
165
|
+
# code << "\n#{" "*spc}#{statement.to_verilog(behavior.block.mode.to_s)}"
|
166
|
+
if statement.is_a?(Block) then
|
167
|
+
code << "\n#{" " * (spc+3)}#{statement.to_verilog(spc+3)}"
|
168
|
+
else
|
169
|
+
code << "\n#{statement.to_verilog(spc+3)}"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
# Close the block."
|
173
|
+
code << "\n#{" "*spc}end"
|
174
|
+
return code
|
118
175
|
end
|
119
176
|
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
120
181
|
# Extract and convert to verilog the TimeRepeat statements.
|
121
182
|
# NOTE: work only on the current level of the block (should be called
|
122
183
|
# through each_block_deep).
|
@@ -136,7 +197,7 @@ class Block
|
|
136
197
|
# Declaration of "inner" part within "always".
|
137
198
|
block.each_inner do |inner|
|
138
199
|
# if regs.include?(inner.name) then
|
139
|
-
if
|
200
|
+
if HDLRuby::Low::VERILOG_REGS.include?(inner.to_verilog) then
|
140
201
|
code << " reg"
|
141
202
|
else
|
142
203
|
code << " wire"
|
@@ -1431,66 +1492,82 @@ class Value
|
|
1431
1492
|
end
|
1432
1493
|
end
|
1433
1494
|
|
1495
|
+
|
1434
1496
|
# Used to transrate if.
|
1435
1497
|
# Enhance If with generation of verilog code.
|
1436
1498
|
class If
|
1437
|
-
# Converts the system to Verilog code.
|
1438
|
-
def to_verilog(mode = nil)
|
1499
|
+
# # Converts the system to Verilog code.
|
1500
|
+
# def to_verilog(mode = nil)
|
1501
|
+
# Converts to Verilog code, checking adding 'spc' spaces at the begining
|
1502
|
+
# of each line.
|
1503
|
+
def to_verilog(spc = 3)
|
1439
1504
|
|
1440
1505
|
$blocking = false
|
1441
1506
|
|
1442
|
-
if ($space_count == 0) then
|
1443
|
-
|
1444
|
-
else
|
1445
|
-
|
1446
|
-
end
|
1447
|
-
$space_count += 1 # Add count to be used for indentation.
|
1507
|
+
# if ($space_count == 0) then
|
1508
|
+
# result = " " * ($space_count) # Indented based on space_count.
|
1509
|
+
# else
|
1510
|
+
# result = ""
|
1511
|
+
# end
|
1512
|
+
# $space_count += 1 # Add count to be used for indentation.
|
1513
|
+
result = " " * spc # Indented based on space_count.
|
1448
1514
|
|
1449
|
-
result << "if (#{self.condition.to_verilog}) begin\n"
|
1515
|
+
# result << "if (#{self.condition.to_verilog}) begin\n"
|
1516
|
+
result << "if (#{self.condition.to_verilog}) "
|
1450
1517
|
|
1451
1518
|
|
1452
1519
|
# Check if there is yes (if) and output yes or less.
|
1453
1520
|
if self.respond_to? (:yes)
|
1454
|
-
self.yes.each_statement do |statement|
|
1455
|
-
|
1456
|
-
end
|
1457
|
-
result << "#{" " * $space_count} end\n"
|
1521
|
+
# self.yes.each_statement do |statement|
|
1522
|
+
# result << "#{" " * $space_count} #{statement.to_verilog(mode)}"
|
1523
|
+
# end
|
1524
|
+
# result << "#{" " * $space_count} end\n"
|
1525
|
+
result << self.yes.to_verilog(spc)
|
1458
1526
|
end
|
1459
1527
|
|
1460
1528
|
# If noif (else if) exists, it outputs it.
|
1461
1529
|
# Since noif is directly under, respond_to is unnecessary.
|
1462
1530
|
self.each_noif do |condition, block|
|
1463
|
-
result << "#{" " * $space_count} else if (#{condition.to_verilog}) begin\n"
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1531
|
+
# result << "#{" " * $space_count} else if (#{condition.to_verilog}) begin\n"
|
1532
|
+
result << "\n#{" "*spc}else if (#{condition.to_verilog}) "
|
1533
|
+
# block.each_statement do |statement|
|
1534
|
+
# result << "#{" " * $space_count} #{statement.to_verilog(mode)}"
|
1535
|
+
# end
|
1536
|
+
# result << "#{" "* $space_count} end\n"
|
1537
|
+
result << block.to_verilog(spc)
|
1468
1538
|
end
|
1469
1539
|
|
1470
1540
|
# Check if there is no (else) and output no or less.
|
1471
|
-
if self.no.respond_to?
|
1472
|
-
result << "#{" " * $space_count} else begin\n"
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1541
|
+
if self.no.respond_to?(:mode)
|
1542
|
+
# result << "#{" " * $space_count} else begin\n"
|
1543
|
+
result << "\n#{" " * spc}else "
|
1544
|
+
# self.no.each_statement do |statement|
|
1545
|
+
# result << "#{" " * $space_count} #{statement.to_verilog(mode)}"
|
1546
|
+
# end
|
1547
|
+
# result << "#{" " * $space_count} end\n"
|
1548
|
+
result << self.no.to_verilog(spc)
|
1477
1549
|
end
|
1478
1550
|
|
1479
|
-
$space_count -= 1 # Since the output ends, reduce the count.
|
1551
|
+
# $space_count -= 1 # Since the output ends, reduce the count.
|
1480
1552
|
return result
|
1481
1553
|
end
|
1482
1554
|
end
|
1483
1555
|
|
1484
1556
|
# Used to translate case
|
1485
1557
|
class Case
|
1486
|
-
def to_verilog(mode = nil)
|
1558
|
+
# def to_verilog(mode = nil)
|
1559
|
+
#
|
1560
|
+
# Converts to Verilog code, checking if variables are register
|
1561
|
+
# or wire adding 'spc' spaces at the begining of each line.
|
1562
|
+
def to_verilog(spc = 3)
|
1487
1563
|
|
1488
|
-
if ($space_count == 0) then
|
1489
|
-
|
1490
|
-
else
|
1491
|
-
|
1492
|
-
end
|
1493
|
-
$space_count += 1 # Add count to be used for indentation.
|
1564
|
+
# if ($space_count == 0) then
|
1565
|
+
# result = " " * ($space_count) # Indented based on space_count.
|
1566
|
+
# else
|
1567
|
+
# result = ""
|
1568
|
+
# end
|
1569
|
+
# $space_count += 1 # Add count to be used for indentation.
|
1570
|
+
result = " " * spc # Indented based on space_count.
|
1494
1571
|
|
1495
1572
|
result = ""
|
1496
1573
|
result << "case(#{self.value.to_verilog})\n"
|
@@ -1498,40 +1575,55 @@ class Case
|
|
1498
1575
|
# n the case statement, each branch is partitioned by when. Process each time when.
|
1499
1576
|
self.each_when do |whens|
|
1500
1577
|
# Reads and stores the numbers and expressions stored in when.
|
1501
|
-
result << " " + " " *$space_count + "#{whens.match.to_verilog}: "
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1578
|
+
# result << " " + " " *$space_count + "#{whens.match.to_verilog}: "
|
1579
|
+
result << " " * (spc+3) + "#{whens.match.to_verilog}: "
|
1580
|
+
|
1581
|
+
# if whens.statement.each_statement.count > 1 then
|
1582
|
+
# result << "begin\n"
|
1583
|
+
# whens.statement.each_statement do |statement|
|
1584
|
+
# result << " "+ " " *$space_count +"#{statement.to_verilog}"
|
1585
|
+
# end
|
1586
|
+
# result << " " + " " *$space_count + "end\n"
|
1587
|
+
# elsif whens.statement.each_statement.count == 1 then
|
1588
|
+
# whens.statement.each_statement do |statement|
|
1589
|
+
# result << "#{statement.to_verilog}"
|
1590
|
+
# end
|
1591
|
+
# else
|
1592
|
+
# # Empty statement case.
|
1593
|
+
# result << "\n"
|
1594
|
+
# end
|
1595
|
+
if whens.statement.each_statement.count >= 1 then
|
1596
|
+
result << whens.statement.to_verilog(spc+3)
|
1512
1597
|
else
|
1513
|
-
# Empty statement case.
|
1514
1598
|
result << "\n"
|
1515
1599
|
end
|
1516
1600
|
end
|
1517
|
-
# The default part is stored in default instead of when. Reads and processes in the same way as when.
|
1601
|
+
# # The default part is stored in default instead of when. Reads and processes in the same way as when.
|
1602
|
+
# if self.default then
|
1603
|
+
# if self.default.each_statement.count > 1 then
|
1604
|
+
# result << " " + " " *$space_count + "default: begin\n"
|
1605
|
+
# self.default.each_statement do |statement|
|
1606
|
+
# result << " " + " " *$space_count + "#{statement.to_verilog}"
|
1607
|
+
# end
|
1608
|
+
# result << " end\n"
|
1609
|
+
# elsif self.default.each_statement.count == 1 then
|
1610
|
+
# result << " " + " " *$space_count + "default: "
|
1611
|
+
# self.default.each_statement do |statement|
|
1612
|
+
# result << "#{statement.to_verilog}"
|
1613
|
+
# end
|
1614
|
+
# end
|
1615
|
+
# end
|
1518
1616
|
if self.default then
|
1519
|
-
if self.default.each_statement.count
|
1520
|
-
result <<
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
result << " end\n"
|
1525
|
-
elsif self.default.each_statement.count == 1 then
|
1526
|
-
result << " " + " " *$space_count + "default: "
|
1527
|
-
self.default.each_statement do |statement|
|
1528
|
-
result << "#{statement.to_verilog}"
|
1529
|
-
end
|
1530
|
-
end
|
1617
|
+
if self.default.each_statement.count >= 1 then
|
1618
|
+
result << self.default.each_statement.to_verilog(spc+3)
|
1619
|
+
else
|
1620
|
+
result << "\n"
|
1621
|
+
end
|
1531
1622
|
end
|
1532
|
-
result << " " + " " *$space_count + "endcase\n" # Conclusion.
|
1623
|
+
# result << " " + " " *$space_count + "endcase\n" # Conclusion.
|
1624
|
+
result << " " * spc + "endcase\n" # Conclusion.
|
1533
1625
|
|
1534
|
-
$space_count -= 1 # Since the output ends, reduce the count.
|
1626
|
+
# $space_count -= 1 # Since the output ends, reduce the count.
|
1535
1627
|
return result # Return case after translation.
|
1536
1628
|
end
|
1537
1629
|
end
|
@@ -1697,8 +1789,9 @@ end
|
|
1697
1789
|
# Look at the unit of time, convert the time to ps and output it.
|
1698
1790
|
# One of two people, TimeWait and Delay.
|
1699
1791
|
class TimeWait
|
1700
|
-
def to_verilog(mode=nil)
|
1701
|
-
|
1792
|
+
# def to_verilog(mode=nil)
|
1793
|
+
def to_verilog(spc = 3)
|
1794
|
+
return (" " * spc) + self.delay.to_verilog + "\n"
|
1702
1795
|
end
|
1703
1796
|
end
|
1704
1797
|
class Delay
|
@@ -1776,15 +1869,9 @@ class SystemT
|
|
1776
1869
|
|
1777
1870
|
# Converts the system to Verilog code.
|
1778
1871
|
def to_verilog
|
1779
|
-
# Preprocessing
|
1780
|
-
# Force seq block to par: ULTRA TEMPORARY! ICIICI
|
1781
|
-
self.each_behavior do |behavior|
|
1782
|
-
behavior.each_block_deep do |block|
|
1783
|
-
block.set_mode!(:par) unless block.is_a?(TimeBlock)
|
1784
|
-
end
|
1785
|
-
end
|
1786
1872
|
# Detect the registers
|
1787
|
-
regs = []
|
1873
|
+
# regs = []
|
1874
|
+
HDLRuby::Low::VERILOG_REGS.clear
|
1788
1875
|
# The left values.
|
1789
1876
|
self.each_behavior do |behavior|
|
1790
1877
|
# behavior.block.each_statement do |statement|
|
@@ -1792,7 +1879,9 @@ class SystemT
|
|
1792
1879
|
# end
|
1793
1880
|
behavior.each_block_deep do |block|
|
1794
1881
|
block.each_statement do |statement|
|
1795
|
-
|
1882
|
+
if statement.is_a?(Transmit)
|
1883
|
+
HDLRuby::Low::VERILOG_REGS << statement.left.to_verilog
|
1884
|
+
end
|
1796
1885
|
end
|
1797
1886
|
end
|
1798
1887
|
end
|
@@ -1809,19 +1898,27 @@ class SystemT
|
|
1809
1898
|
# # puts "Now regs has clk?: #{regs.include?("clk")}"
|
1810
1899
|
# And the initialized signals.
|
1811
1900
|
self.each_output do |output|
|
1812
|
-
regs << output.to_verilog if output.value
|
1901
|
+
# regs << output.to_verilog if output.value
|
1902
|
+
HDLRuby::Low::VERILOG_REGS << output.to_verilog if output.value
|
1813
1903
|
end
|
1814
1904
|
self.each_inner do |inner|
|
1815
|
-
regs << inner.to_verilog if inner.value
|
1905
|
+
# regs << inner.to_verilog if inner.value
|
1906
|
+
HDLRuby::Low::VERILOG_REGS << inner.to_verilog if inner.value
|
1816
1907
|
end
|
1817
1908
|
# And the array types signals.
|
1818
1909
|
self.each_signal do |sig|
|
1819
|
-
# regs << sig.to_verilog if sig.type.is_a?(TypeVector) && sig.type.base.is_a?(TypeVector)
|
1820
|
-
regs << sig.to_verilog if sig.type.vector? && sig.type.base.vector?
|
1910
|
+
# # regs << sig.to_verilog if sig.type.is_a?(TypeVector) && sig.type.base.is_a?(TypeVector)
|
1911
|
+
# regs << sig.to_verilog if sig.type.vector? && sig.type.base.vector?
|
1912
|
+
if sig.type.vector? && sig.type.base.vector? then
|
1913
|
+
HDLRuby::Low::VERILOG_REGS << sig.to_verilog
|
1914
|
+
end
|
1821
1915
|
end
|
1822
1916
|
self.each_inner do |sig|
|
1823
|
-
# regs << sig.to_verilog if sig.type.is_a?(TypeVector) && sig.type.base.is_a?(TypeVector)
|
1824
|
-
regs << sig.to_verilog if sig.type.vector? && sig.type.base.vector?
|
1917
|
+
# # regs << sig.to_verilog if sig.type.is_a?(TypeVector) && sig.type.base.is_a?(TypeVector)
|
1918
|
+
# regs << sig.to_verilog if sig.type.vector? && sig.type.base.vector?
|
1919
|
+
if sig.type.vector? && sig.type.base.vector? then
|
1920
|
+
HDLRuby::Low::VERILOG_REGS << sig.to_verilog
|
1921
|
+
end
|
1825
1922
|
end
|
1826
1923
|
|
1827
1924
|
# Code generation
|
@@ -1890,7 +1987,8 @@ class SystemT
|
|
1890
1987
|
$vector_reg = "#{output.to_verilog}"
|
1891
1988
|
$vector_cnt = 0
|
1892
1989
|
output.type.each_type do |type|
|
1893
|
-
if regs.include?(type.name) then
|
1990
|
+
# if regs.include?(type.name) then
|
1991
|
+
if HDLRuby::Low::VERILOG_REGS.include?(type.name) then
|
1894
1992
|
code << " output reg"
|
1895
1993
|
else
|
1896
1994
|
code << " output"
|
@@ -1906,7 +2004,8 @@ class SystemT
|
|
1906
2004
|
end
|
1907
2005
|
else
|
1908
2006
|
# if regs.include?(output.name) then
|
1909
|
-
if regs.include?(output.to_verilog) then
|
2007
|
+
# if regs.include?(output.to_verilog) then
|
2008
|
+
if HDLRuby::Low::VERILOG_REGS.include?(output.to_verilog) then
|
1910
2009
|
code << " output reg"
|
1911
2010
|
else
|
1912
2011
|
code << " output"
|
@@ -1937,8 +2036,9 @@ class SystemT
|
|
1937
2036
|
|
1938
2037
|
# Declare "inner".
|
1939
2038
|
self.each_inner do |inner|
|
1940
|
-
# if regs.include?(inner.name) then
|
1941
|
-
if regs.include?(inner.to_verilog) then
|
2039
|
+
# # if regs.include?(inner.name) then
|
2040
|
+
# if regs.include?(inner.to_verilog) then
|
2041
|
+
if HDLRuby::Low::VERILOG_REGS.include?(inner.to_verilog) then
|
1942
2042
|
code << " reg"
|
1943
2043
|
else
|
1944
2044
|
code << " wire"
|
@@ -1966,8 +2066,9 @@ class SystemT
|
|
1966
2066
|
# If there is scope in scope, translate it.
|
1967
2067
|
self.each_scope do |scope|
|
1968
2068
|
scope.each_inner do |inner|
|
1969
|
-
# if regs.include?(inner.name) then
|
1970
|
-
if regs.include?(inner.to_verilog) then
|
2069
|
+
# # if regs.include?(inner.name) then
|
2070
|
+
# if regs.include?(inner.to_verilog) then
|
2071
|
+
if HDLRuby::Low::VERILOG_REGS.include?(inner.to_verilog) then
|
1971
2072
|
code << " reg "
|
1972
2073
|
else
|
1973
2074
|
code << " wire "
|
@@ -2058,7 +2159,8 @@ class SystemT
|
|
2058
2159
|
code << blk.repeat_to_verilog!
|
2059
2160
|
end
|
2060
2161
|
# And generate an initial block.
|
2061
|
-
code << " initial begin\n"
|
2162
|
+
# code << " initial begin\n"
|
2163
|
+
code << " initial "
|
2062
2164
|
else
|
2063
2165
|
# Generate a standard process.
|
2064
2166
|
code << " always @( "
|
@@ -2083,54 +2185,57 @@ class SystemT
|
|
2083
2185
|
code << "#{event.last.type.to_s} #{event.last.ref.to_verilog}"
|
2084
2186
|
end
|
2085
2187
|
end
|
2086
|
-
code << " ) begin\n"
|
2188
|
+
# code << " ) begin\n"
|
2189
|
+
code << " ) "
|
2087
2190
|
end
|
2088
2191
|
|
2089
|
-
# Perform "scheduling" using the method "flatten".
|
2090
|
-
block = behavior.block.flatten(behavior.block.mode.to_s)
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
end
|
2192
|
+
# # Perform "scheduling" using the method "flatten".
|
2193
|
+
# block = behavior.block.flatten(behavior.block.mode.to_s)
|
2194
|
+
# code << block.to_verilog(regs)
|
2195
|
+
code << behavior.block.to_verilog
|
2196
|
+
|
2197
|
+
# # Declaration of "inner" part within "always".
|
2198
|
+
# block.each_inner do |inner|
|
2199
|
+
# # if regs.include?(inner.name) then
|
2200
|
+
# if regs.include?(inner.to_verilog) then
|
2201
|
+
# code << " reg"
|
2202
|
+
# else
|
2203
|
+
# code << " wire"
|
2204
|
+
# end
|
2205
|
+
|
2206
|
+
# # Variable has "base", but if there is width etc, it is not in "base".
|
2207
|
+
# # It is determined by an if.
|
2208
|
+
# if inner.type.base?
|
2209
|
+
# if inner.type.base.base?
|
2210
|
+
# # code << "#{inner.type.base.to_verilog} #{inner.to_verilog} #{inner.type.to_verilog};\n"
|
2211
|
+
# code << "#{inner.type.base.to_verilog} #{inner.to_verilog} #{inner.type.to_verilog}"
|
2212
|
+
# else
|
2213
|
+
# # code << "#{inner.type.to_verilog} #{inner.to_verilog};\n"
|
2214
|
+
# code << "#{inner.type.to_verilog} #{inner.to_verilog}"
|
2215
|
+
# end
|
2216
|
+
# else
|
2217
|
+
# # code << " #{inner.type.to_verilog}#{inner.to_verilog};\n"
|
2218
|
+
# code << " #{inner.type.to_verilog}#{inner.to_verilog}"
|
2219
|
+
# end
|
2220
|
+
# if inner.value then
|
2221
|
+
# # There is an initial value.
|
2222
|
+
# code << " = #{inner.value.to_verilog}"
|
2223
|
+
# end
|
2224
|
+
# code << ";\n"
|
2225
|
+
# end
|
2121
2226
|
|
2122
|
-
# Translate the block that finished scheduling.
|
2123
|
-
block.each_statement do |statement|
|
2124
|
-
|
2125
|
-
end
|
2227
|
+
# # Translate the block that finished scheduling.
|
2228
|
+
# block.each_statement do |statement|
|
2229
|
+
# code << "\n #{statement.to_verilog(behavior.block.mode.to_s)}"
|
2230
|
+
# end
|
2126
2231
|
|
2127
|
-
$fm.fm_par.clear()
|
2232
|
+
# $fm.fm_par.clear()
|
2128
2233
|
|
2129
|
-
code << "\n end\n\n"
|
2234
|
+
# code << "\n end\n\n"
|
2130
2235
|
end
|
2131
2236
|
|
2132
2237
|
# Conclusion.
|
2133
|
-
code << "
|
2238
|
+
code << "\nendmodule"
|
2134
2239
|
return code
|
2135
2240
|
end
|
2136
2241
|
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.4.
|
4
|
+
version: 2.4.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lovic Gauthier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/HDLRuby/hdr_samples/register_with_code_bench.rb
|
117
117
|
- lib/HDLRuby/hdr_samples/rom.rb
|
118
118
|
- lib/HDLRuby/hdr_samples/ruby_fir_hw.rb
|
119
|
+
- lib/HDLRuby/hdr_samples/seqpar_bench.rb
|
119
120
|
- lib/HDLRuby/hdr_samples/struct.rb
|
120
121
|
- lib/HDLRuby/hdr_samples/sumprod.rb
|
121
122
|
- lib/HDLRuby/hdr_samples/sw_encrypt_bench.rb
|
@@ -221,6 +222,7 @@ files:
|
|
221
222
|
- lib/HDLRuby/hruby_low_without_connection.rb
|
222
223
|
- lib/HDLRuby/hruby_low_without_namespace.rb
|
223
224
|
- lib/HDLRuby/hruby_low_without_outread.rb
|
225
|
+
- lib/HDLRuby/hruby_low_without_parinseq.rb
|
224
226
|
- lib/HDLRuby/hruby_low_without_select.rb
|
225
227
|
- lib/HDLRuby/hruby_serializer.rb
|
226
228
|
- lib/HDLRuby/hruby_tools.rb
|