Module: ClassHDL
- Defined in:
- lib/tdl/exlib/test_point.rb,
lib/tdl/exlib/test_point.rb,
lib/tdl/class_hdl/hdl_assign.rb,
lib/tdl/class_hdl/hdl_random.rb,
lib/tdl/class_hdl/hdl_struct.rb,
lib/tdl/class_hdl/hdl_verify.rb,
lib/tdl/class_hdl/hdl_foreach.rb,
lib/tdl/class_hdl/hdl_initial.rb,
lib/tdl/class_hdl/hdl_package.rb,
lib/tdl/class_hdl/hdl_function.rb,
lib/tdl/class_hdl/hdl_generate.rb,
lib/tdl/class_hdl/hdl_always_ff.rb,
lib/tdl/class_hdl/hdl_module_def.rb,
lib/tdl/class_hdl/hdl_module_def.rb,
lib/tdl/class_hdl/hdl_module_def.rb,
lib/tdl/class_hdl/hdl_always_comb.rb,
lib/tdl/class_hdl/hdl_block_ifelse.rb,
lib/tdl/class_hdl/hdl_block_ifelse.rb,
lib/tdl/class_hdl/hdl_redefine_opertor.rb,
lib/tdl/class_hdl/hdl_redefine_opertor.rb,
lib/tdl/class_hdl/hdl_redefine_opertor.rb,
lib/tdl/class_hdl/hdl_redefine_opertor.rb
Overview
Defined Under Namespace
Modules: AssignDefOpertor, RandomNum
Classes: BlocAssertIF, BlockCASE, BlockCASEDEFAULT, BlockCASEWHEN, BlockCASEX, BlockELSE, BlockELSIF, BlockFOR, BlockFOREACH, BlockIF, ClassEdge, ClassNegedge, ClassPosedge, ClearGenerateSlaverBlock, ClearSdlModule, DefFunction, DefStruct, EnumStruct, GenerateBlock, GlobalVar, HDLAlwaysBlock, HDLAlwaysCombBlock, HDLAlwaysFFBlock, HDLAlwaysSIMBlock, HDLAssignBlock, HDLAssignGenerateBlock, HDLFunction, HDLFunctionIvoke, HDLInitialBlock, ImplicitInstModule, ImplicitPortBase, ImplicitPortBasePackage, ImplicitPortInout, ImplicitPortInput, ImplicitPortOutput, OpertorChain, SdlPackage, StructBlock, StructMeta, StructVar, Verify
Constant Summary
collapse
- OP_SYMBOLS =
%w{+ - * / % > < >= <= == != << | & ^}
Class Method Summary
collapse
-
.Always(sdl_m: nil, posedge: [], negedge: [], &block) ⇒ Object
-
.AlwaysComb(sdl_m, &block) ⇒ Object
-
.AlwaysFF(sdl_m: nil, posedge: [], negedge: [], &block) ⇒ Object
-
.AlwaysSIM(sdl_m: nil, posedge: [], negedge: [], &block) ⇒ Object
-
.Assign(sdl_m, &block) ⇒ Object
-
.compact_op_ch(str) ⇒ Object
-
.define_func_block_method(sdlm, *argv) ⇒ Object
-
.disable_SdlModule_port ⇒ Object
redefine sdlmodule input output.
-
.enable_SdlModule_port ⇒ Object
-
.Function(sdl_m, name, return_type, *argvs, &block) ⇒ Object
-
.Initial(sdl_m, block_name = nil, &block) ⇒ Object
-
.new_def_SdlModule_port ⇒ Object
-
.remove_func_block_method(sdlm, *argv) ⇒ Object
-
.Struct(name, sdlm, pre_type, &block) ⇒ Object
-
.with_disable_SdlModule_port(&block) ⇒ Object
Class Method Details
.Always(sdl_m: nil, posedge: [], negedge: [], &block) ⇒ Object
.AlwaysComb(sdl_m, &block) ⇒ Object
.AlwaysFF(sdl_m: nil, posedge: [], negedge: [], &block) ⇒ Object
.AlwaysSIM(sdl_m: nil, posedge: [], negedge: [], &block) ⇒ Object
.Assign(sdl_m, &block) ⇒ Object
.compact_op_ch(str) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/tdl/class_hdl/hdl_redefine_opertor.rb', line 32
def self.compact_op_ch(str)
if str =~ /^(?<head>[\w\.\[\]\:]+\s*)(?<eq><?=\s*)\((?<body>.+)\)$/
rel_str = $~[:head] + $~[:eq] + $~[:body]
else
rel_str = str
end
end
|
.define_func_block_method(sdlm, *argv) ⇒ Object
247
248
249
250
251
252
253
|
# File 'lib/tdl/class_hdl/hdl_function.rb', line 247
def self.define_func_block_method(sdlm,*argv)
argv.each do |e|
sdlm.define_singleton_method(e.name) do
e
end
end
end
|
.disable_SdlModule_port ⇒ Object
redefine sdlmodule input output
171
172
173
174
175
176
177
178
|
# File 'lib/tdl/class_hdl/hdl_function.rb', line 171
def self.disable_SdlModule_port
symbs = [:Input,:Output,:Inout]
symbs.each do |symb|
SdlModule.class_eval do
alias_method "_function_bak_#{symb}__",symb
end
end
end
|
.enable_SdlModule_port ⇒ Object
180
181
182
183
184
185
186
187
|
# File 'lib/tdl/class_hdl/hdl_function.rb', line 180
def self.enable_SdlModule_port
symbs = [:Input,:Output,:Inout]
symbs.each do |symb|
SdlModule.class_eval do
alias_method symb,"_function_bak_#{symb}__"
end
end
end
|
.Function(sdl_m, name, return_type, *argvs, &block) ⇒ Object
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
# File 'lib/tdl/class_hdl/hdl_function.rb', line 120
def self.Function(sdl_m,name,return_type,*argvs,&block)
define_func_block_method(sdl_m,*argvs)
func_inst = ClassHDL::HDLFunction.new(sdl_m,name,return_type,*argvs)
sdl_m.define_singleton_method(name) do |*fargvs|
fargvs.each do |e|
if e.is_a? OpertorChain
e.slaver = true
end
end
HDLFunctionIvoke.new(func_inst,*fargvs)
end
ClassHDL::AssignDefOpertor.with_new_assign_block(func_inst) do |ab|
AssignDefOpertor.with_rollback_opertors(:old) do
argvs.each do |e|
end
end
AssignDefOpertor.with_rollback_opertors(:new,&block)
AssignDefOpertor.with_rollback_opertors(:old) do
sdl_m.Logic_draw.push ab.instance
end
end
remove_func_block_method(sdl_m,*argvs)
func_inst.open_ivoke = true
end
|
.Initial(sdl_m, block_name = nil, &block) ⇒ Object
.new_def_SdlModule_port ⇒ Object
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
# File 'lib/tdl/class_hdl/hdl_function.rb', line 189
def self.new_def_SdlModule_port
SdlModule.class_eval do
def Input(name,dsize:1,dimension:[],pin:[],iostd:[],pin_prop:nil)
port_name_chk(name)
ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do
tmp = Logic.new(name:name,dsize:dsize,port:"input",dimension:dimension, belong_to_module: self)
tmp
end
end
def Output(name,dsize:1,dimension:[],pin:[],iostd:[],pin_prop:nil)
port_name_chk(name)
ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do
tmp = Logic.new(name:name,dsize:dsize,port:"output logic",dimension:dimension, belong_to_module: self)
if block_given?
yield(tmp)
end
tmp
end
end
def Inout(name,dsize:1,dimension:[],pin:[],iostd:[],pin_prop:nil)
port_name_chk(name)
ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do
tmp = Logic.new(name:name,dsize:dsize,port:"inout",dimension:dimension)
if block_given?
yield(tmp)
end
tmp
end
end
end
end
|
.remove_func_block_method(sdlm, *argv) ⇒ Object
255
256
257
258
259
260
261
262
|
# File 'lib/tdl/class_hdl/hdl_function.rb', line 255
def self.remove_func_block_method(sdlm,*argv)
argv.each do |e|
sdlm.instance_eval("undef #{e.name}")
end
end
|
.Struct(name, sdlm, pre_type, &block) ⇒ Object
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
|
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 16
def self.Struct(name,sdlm,pre_type,&block)
tmp_sm = ClassHDL::StructBlock.new(sdlm)
ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do
tmp_sm.instance_exec(&block)
end
str = (tmp_sm.vars_define_inst + "\n")
str.gsub!(/\/\/.*/,"")
str.gsub!(/[\t|\n]+/m,"\n")
unless pre_type.to_s == 'union'
head_str = "typedef struct #{pre_type}{\n"
else
head_str = "typedef union {\n"
end
end_str = "} #{name.to_s};\n"
mstr = String.new(head_str+str+end_str)
mstr.define_singleton_method("inst") do
self
end
sdlm.Logic_collect << mstr
all_collect = []
SdlModule.class_variable_get('@@ele_array').each do |e|
head_str = e.to_s
all_collect = all_collect + tmp_sm.send("#{head_str}_collect")
end
return all_collect
end
|
.with_disable_SdlModule_port(&block) ⇒ Object
239
240
241
242
243
244
245
|
# File 'lib/tdl/class_hdl/hdl_function.rb', line 239
def self.with_disable_SdlModule_port(&block)
disable_SdlModule_port
new_def_SdlModule_port
rel = block.call
enable_SdlModule_port
rel
end
|