axi_tdl 0.1.0 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -0
  3. data/lib/axi/AXI4/axi4_direct_A1.sv +1 -1
  4. data/lib/axi/AXI4/axi4_direct_verc.sv +54 -54
  5. data/lib/axi/AXI4/axi4_dpram_cache.rb +1 -0
  6. data/lib/axi/AXI4/axi4_dpram_cache.sv +10 -10
  7. data/lib/axi/AXI4/axi4_rd_burst_track.sv +2 -1
  8. data/lib/axi/AXI4/axi4_wr_burst_track.sv +2 -1
  9. data/lib/axi/AXI4/axis_to_axi4_wr.sv +9 -9
  10. data/lib/axi/AXI4/odata_pool_axi4_A3.sv +7 -0
  11. data/lib/axi/AXI4/packet_partition/axi4_partition_rd_verb.sv +5 -5
  12. data/lib/axi/AXI4/packet_partition/data_inf_partition.rb +8 -4
  13. data/lib/axi/AXI4/packet_partition/data_inf_partition.sv +6 -6
  14. data/lib/axi/AXI4/wide_axis_to_axi4_wr.sv +12 -12
  15. data/lib/axi/AXI_stream/axi_stream_split_channel.sv +154 -0
  16. data/lib/axi/AXI_stream/axis_head_cut_verc.sv +242 -0
  17. data/lib/axi/AXI_stream/axis_insert_copy.sv +79 -0
  18. data/lib/axi/AXI_stream/axis_pipe_sync_seam.sv +48 -0
  19. data/lib/axi/AXI_stream/axis_rom_contect_sim.sv +113 -0
  20. data/lib/axi/AXI_stream/axis_sim_master_model.rb +2 -0
  21. data/lib/axi/AXI_stream/axis_sim_master_model.sv +46 -0
  22. data/lib/axi/AXI_stream/axis_split_channel_verb.sv +62 -0
  23. data/lib/axi/AXI_stream/data_width/axis_width_convert_verb.sv +50 -0
  24. data/lib/axi/AXI_stream/packet_fifo/axi_stream_packet_long_fifo.sv +2 -0
  25. data/lib/axi/AXI_stream/parse_big_field_table_verb.sv +5 -3
  26. data/lib/axi/common/common_ram_sim_wrapper.sv +1 -1
  27. data/lib/axi/common/common_ram_wrapper.sv +1 -1
  28. data/lib/axi/common/test_write_mem.sv +1 -1
  29. data/lib/axi/data_interface/data_inf_c/data_c_pipe_sync_seam.sv +13 -13
  30. data/lib/axi/data_interface/data_inf_c/data_c_sim_master_model.sv +14 -11
  31. data/lib/axi/platform_ip/fifo_36kb_long.sv +1 -1
  32. data/lib/axi/platform_ip/long_fifo_verb.sv +1 -1
  33. data/lib/axi/platform_ip/wide_fifo.sv +1 -1
  34. data/lib/axi/platform_ip/xilinx_fifo_verb.sv +1 -1
  35. data/lib/axi/platform_ip/xilinx_fifo_verc.sv +2 -1
  36. data/lib/axi/techbench/tb_axi_stream_split_channel.rb +2 -1
  37. data/lib/axi/techbench/tb_axi_stream_split_channel.sv +46 -45
  38. data/lib/axi_tdl.rb +31 -1
  39. data/lib/axi_tdl/version.rb +1 -1
  40. data/lib/public_atom_module/CheckPClock.sv +53 -0
  41. data/lib/public_atom_module/LICENSE.md +674 -0
  42. data/lib/public_atom_module/altera_xilinx_always_block_sw.rb +57 -0
  43. data/lib/public_atom_module/bits_decode.sv +71 -0
  44. data/lib/public_atom_module/bits_decode_verb.sv +71 -0
  45. data/lib/public_atom_module/bits_decode_verb_sdl.rb +24 -0
  46. data/lib/public_atom_module/broaden.v +43 -0
  47. data/lib/public_atom_module/broaden_and_cross_clk.v +47 -0
  48. data/lib/public_atom_module/ceiling.v +39 -0
  49. data/lib/public_atom_module/ceiling_A1.v +42 -0
  50. data/lib/public_atom_module/clock_rst.sv +64 -0
  51. data/lib/public_atom_module/cross_clk_sync.v +37 -0
  52. data/lib/public_atom_module/edge_generator.v +50 -0
  53. data/lib/public_atom_module/flooring.v +36 -0
  54. data/lib/public_atom_module/latch_data.v +30 -0
  55. data/lib/public_atom_module/latency.v +48 -0
  56. data/lib/public_atom_module/latency_dynamic.v +83 -0
  57. data/lib/public_atom_module/latency_long.v +84 -0
  58. data/lib/public_atom_module/latency_verb.v +52 -0
  59. data/lib/public_atom_module/once_event.sv +65 -0
  60. data/lib/public_atom_module/pipe_reg.v +93 -0
  61. data/lib/public_atom_module/pipe_reg_2write_ports.v +84 -0
  62. data/lib/public_atom_module/sim/clock_rst_verb.sv +54 -0
  63. data/lib/public_atom_module/sim/clock_rst_verc.sv +69 -0
  64. data/lib/public_atom_module/sim/latency_long_tb.sv +49 -0
  65. data/lib/public_atom_module/sim/latency_long_tb.sv.bak +49 -0
  66. data/lib/public_atom_module/sim_system_pkg.sv +4 -0
  67. data/lib/public_atom_module/synth_system_pkg.sv +4 -0
  68. data/lib/tdl/Logic/logic_edge.rb +1 -1
  69. data/lib/tdl/auto_script/autogensdl.rb +2 -3
  70. data/lib/tdl/auto_script/import_hdl.rb +40 -5
  71. data/lib/tdl/axi4/axi4_interconnect_verb.rb +47 -10
  72. data/lib/tdl/class_hdl/hdl_always_comb.rb +4 -1
  73. data/lib/tdl/class_hdl/hdl_always_ff.rb +3 -3
  74. data/lib/tdl/class_hdl/hdl_assign.rb +7 -1
  75. data/lib/tdl/class_hdl/hdl_block_ifelse.rb +7 -7
  76. data/lib/tdl/class_hdl/hdl_foreach.rb +2 -2
  77. data/lib/tdl/class_hdl/hdl_function.rb +4 -4
  78. data/lib/tdl/class_hdl/hdl_generate.rb +5 -2
  79. data/lib/tdl/class_hdl/hdl_initial.rb +25 -3
  80. data/lib/tdl/class_hdl/hdl_module_def.rb +9 -6
  81. data/lib/tdl/class_hdl/hdl_package.rb +45 -0
  82. data/lib/tdl/class_hdl/hdl_redefine_opertor.rb +99 -27
  83. data/lib/tdl/class_hdl/hdl_struct.rb +2 -2
  84. data/lib/tdl/elements/Reset.rb +5 -9
  85. data/lib/tdl/elements/clock.rb +5 -9
  86. data/lib/tdl/elements/data_inf.rb +0 -17
  87. data/lib/tdl/elements/logic.rb +9 -31
  88. data/lib/tdl/elements/mail_box.rb +6 -1
  89. data/lib/tdl/elements/originclass.rb +17 -47
  90. data/lib/tdl/elements/parameter.rb +5 -6
  91. data/lib/tdl/examples/11_test_unit/dve.tcl +6 -153
  92. data/lib/tdl/examples/11_test_unit/exp_test_unit.sv +2 -2
  93. data/lib/tdl/examples/11_test_unit/exp_test_unit_sim.sv +9 -0
  94. data/lib/tdl/examples/11_test_unit/modules/sub_md0.sv +2 -2
  95. data/lib/tdl/examples/11_test_unit/modules/sub_md1.sv +2 -2
  96. data/lib/tdl/examples/11_test_unit/tb_exp_test_unit.sv +1 -1
  97. data/lib/tdl/examples/11_test_unit/tb_exp_test_unit_sim.sv +41 -0
  98. data/lib/tdl/examples/11_test_unit/tu0.sv +2 -1
  99. data/lib/tdl/examples/1_define_module/exmple_md.sv +1 -1
  100. data/lib/tdl/examples/2_hdl_class/tmp/always_comb_test.sv +3 -3
  101. data/lib/tdl/examples/2_hdl_class/tmp/always_ff_test.sv +3 -3
  102. data/lib/tdl/examples/2_hdl_class/tmp/case_test.sv +3 -3
  103. data/lib/tdl/examples/2_hdl_class/tmp/module_instance_test.sv +1 -1
  104. data/lib/tdl/examples/2_hdl_class/tmp/simple_assign_test.sv +3 -3
  105. data/lib/tdl/examples/2_hdl_class/tmp/state_case_test.sv +3 -3
  106. data/lib/tdl/examples/2_hdl_class/tmp/test_inst_sugar.sv +1 -1
  107. data/lib/tdl/examples/2_hdl_class/tmp/test_module.sv +3 -3
  108. data/lib/tdl/examples/2_hdl_class/tmp/test_module_port.sv +2 -2
  109. data/lib/tdl/examples/2_hdl_class/tmp/test_module_var.sv +7 -7
  110. data/lib/tdl/examples/2_hdl_class/tmp/test_package.sv +4 -3
  111. data/lib/tdl/examples/2_hdl_class/tmp/test_vcs_string.sv +1 -1
  112. data/lib/tdl/examples/3_hdl_sdl_instance/main_md.sv +2 -2
  113. data/lib/tdl/examples/3_hdl_sdl_instance/sdl_md.sv +1 -1
  114. data/lib/tdl/examples/6_module_with_interface/example_interface.sv +8 -8
  115. data/lib/tdl/examples/6_module_with_interface/inf_collect.sv +9 -9
  116. data/lib/tdl/examples/7_module_with_package/body_package.sv +4 -3
  117. data/lib/tdl/examples/7_module_with_package/example_pkg.sv +1 -1
  118. data/lib/tdl/examples/7_module_with_package/head_package.sv +4 -3
  119. data/lib/tdl/examples/8_top_module/dve.tcl +6 -0
  120. data/lib/tdl/examples/8_top_module/tb_test_top.sv +1 -1
  121. data/lib/tdl/examples/8_top_module/tb_test_top_sim.sv +29 -0
  122. data/lib/tdl/examples/8_top_module/test_top.sv +1 -1
  123. data/lib/tdl/examples/8_top_module/test_top_sim.sv +9 -0
  124. data/lib/tdl/examples/9_itegration/clock_manage/test_clock_bb.sv +2 -1
  125. data/lib/tdl/examples/9_itegration/dve.tcl +155 -2
  126. data/lib/tdl/examples/9_itegration/tb_test_tttop.sv +1 -1
  127. data/lib/tdl/examples/9_itegration/tb_test_tttop_sim.sv +1 -1
  128. data/lib/tdl/examples/9_itegration/test_tttop.sv +7 -38
  129. data/lib/tdl/examples/9_itegration/test_tttop_sim.sv +38 -7
  130. data/lib/tdl/exlib/axis_verify.rb +4 -3
  131. data/lib/tdl/exlib/constraints_verb.rb +1 -0
  132. data/lib/tdl/exlib/itegration_verb.rb +47 -41
  133. data/lib/tdl/rebuild_ele/ele_base.rb +15 -10
  134. data/lib/tdl/sdlmodule/sdlmodule.rb +117 -51
  135. data/lib/tdl/sdlmodule/sdlmodule_arraychain.rb +1 -1
  136. data/lib/tdl/sdlmodule/sdlmodule_draw.rb +2 -2
  137. data/lib/tdl/sdlmodule/sdlmodule_instance.rb +3 -0
  138. data/lib/tdl/sdlmodule/sdlmodule_port_define.rb +6 -6
  139. data/lib/tdl/sdlmodule/sdlmodule_varible.rb +6 -6
  140. data/lib/tdl/sdlmodule/test_unit_module.rb +6 -0
  141. data/lib/tdl/sdlmodule/top_module.rb +4 -0
  142. data/lib/tdl/tdl.rb +1 -11
  143. data/lib/tdl/tdlerror/tdlerror.rb +1 -1
  144. metadata +43 -5
  145. data/CODE_OF_CONDUCT.md +0 -74
  146. data/lib/axi/AXI_stream/axis_length_split_writh_user.sv +0 -87
@@ -0,0 +1,57 @@
1
+ file_root_path = File.dirname(File.expand_path(__FILE__))
2
+ # file_name = "/home/young/work/public_atom_modules/latency.v"
3
+ $mode = "xilinx"
4
+ def sw_always(to="xilinx",file_name)
5
+ all_str = File.open(file_name).read
6
+ altera_rep_0 = /always\s*@\s*\(\s*posedge\s+(?<clock_name>\w*(?i:clock|clk)\w*)\s*(?:,|or)\s*negedge\s+(?<rst_name>\w*(?:rst|reset)\w*)\s*\)/
7
+ xilinx_rep = /always\s*@\s*\(posedge\s+(?<clock_name>\w*(?i:clock|clk)\w*)\s*\/\*.+\*\/\s*\)/
8
+ # altera_rep_0 = /always\s*@\s*\(\s*posedge\s+(?<clock_name>\s*(?i:clock|clk)\s*)\t*(?:,|or)\s*/
9
+ if(to.downcase=="xilinx")
10
+ all_str.gsub!(altera_rep_0) do |s|
11
+ "always@(posedge #{$~["clock_name"]}/*,negedge #{$~["rst_name"]}*/)"
12
+ end
13
+ elsif to.downcase=="altera"
14
+ all_str.gsub!(xilinx_rep) do |s|
15
+ s.sub('/*','').sub('*/','')
16
+ end
17
+ end
18
+
19
+ # if xilinx_rep.match("always@(posedge clk/*,negedge rst_n*/)")
20
+ # puts "rep OK"
21
+ # puts $~["clock_name"]
22
+ # else
23
+ # puts "rep ERR"
24
+ # end
25
+ File.open(file_name,"w"){|f| f.print(all_str)}
26
+ end
27
+
28
+ def look_for_v(path)
29
+ paths = Dir::entries(path) - %w{. ..}
30
+
31
+ paths.each do |pf|
32
+ full_name = File.join(path,pf)
33
+ if(File.directory? full_name)
34
+ look_for_v(full_name)
35
+ elsif(File.file? full_name)
36
+ if(/\.v$/i =~ pf || /\.sv$/i =~ pf)
37
+ sw_always($mode,full_name)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ if ARGV.empty?
44
+ puts "Pleace switch to xilinx or altera"
45
+ elsif ARGV[0] == "xilinx"
46
+ $mode = "xilinx"
47
+ look_for_v(file_root_path)
48
+ elsif ARGV[0] == "altera"
49
+ $mode = "altera"
50
+ look_for_v(file_root_path)
51
+ else
52
+ puts "error ARVG"
53
+ end
54
+
55
+
56
+ # sw_always("xilinx",file_name)
57
+ # sw_always("altera",file_name)
@@ -0,0 +1,71 @@
1
+ /**********************************************
2
+ ______________ ______________
3
+ ______________ \ /\ /|\ /| ______________
4
+ ______________ \/ \/ | \/ | ______________
5
+ descript:
6
+ author : Young
7
+ Version:
8
+ creaded: xxxx.xx.xx
9
+ madified:
10
+ ***********************************************/
11
+ `timescale 1ns/1ps
12
+ module bits_decode_nc_verb #(
13
+ parameter NUM = 16,
14
+ parameter NSIZE = $clog2(NUM),
15
+ parameter MODE = "H" //Hight BIT first
16
+ )(
17
+ input [NUM-1:0] origin_bits,
18
+ output logic [NSIZE-1:0] code
19
+ );
20
+
21
+ int KK;
22
+ generate
23
+ if(MODE!="H")begin
24
+ always_comb begin
25
+ code = NUM-1;
26
+ for(KK=NUM;KK>0;KK--)begin
27
+ if(origin_bits[KK-1])
28
+ code = KK-1;
29
+ else code = code;
30
+ end
31
+ end
32
+ end else begin
33
+ always_comb begin
34
+ code = 0;
35
+ for(KK=0;KK<NUM;KK++)begin
36
+ if(origin_bits[KK])
37
+ code = KK;
38
+ else code = code;
39
+ end
40
+ end
41
+ end
42
+ endgenerate
43
+
44
+ endmodule : bits_decode_nc_verb
45
+
46
+ module bits_decode_verb #(
47
+ parameter NUM = 16,
48
+ parameter NSIZE = $clog2(NUM),
49
+ parameter MODE = "H" //Hight BIT first
50
+ )(
51
+ input clock,
52
+ input rst_n,
53
+ input [NUM-1:0] origin_bits,
54
+ output logic [NSIZE-1:0] code
55
+ );
56
+
57
+ logic [NSIZE-1:0] tmp;
58
+
59
+ bits_decode_nc_verb #(
60
+ .NUM (NUM ),
61
+ .MODE (MODE ) //Hight BIT first
62
+ )bits_decode_nc_inst(
63
+ /* input [NUM-1:0] */ .origin_bits (origin_bits ),
64
+ /* output logic [NSIZE-1:0] */ .code (tmp )
65
+ );
66
+
67
+ always@(posedge clock,negedge rst_n)
68
+ if(~rst_n) code <= '0;
69
+ else code <= tmp;
70
+
71
+ endmodule:bits_decode_verb
@@ -0,0 +1,71 @@
1
+ /**********************************************
2
+ ______________ ______________
3
+ ______________ \ /\ /|\ /| ______________
4
+ ______________ \/ \/ | \/ | ______________
5
+ descript:
6
+ author : Young
7
+ Version:
8
+ creaded: XXXX.XX.XX
9
+ madified:
10
+ ***********************************************/
11
+ `timescale 1ns/1ps
12
+ module bits_decode_nc #(
13
+ parameter NUM = 16,
14
+ parameter NSIZE = $clog2(NUM),
15
+ parameter MODE = "H" //Hight BIT first
16
+ )(
17
+ input [NUM-1:0] bits,
18
+ output logic [NSIZE-1:0] code
19
+ );
20
+
21
+ int KK;
22
+ generate
23
+ if(MODE!="H")begin
24
+ always_comb begin
25
+ code = NUM-1;
26
+ for(KK=NUM;KK>0;KK--)begin
27
+ if(bits[KK-1])
28
+ code = KK-1;
29
+ else code = code;
30
+ end
31
+ end
32
+ end else begin
33
+ always_comb begin
34
+ code = 0;
35
+ for(KK=0;KK<NUM;KK++)begin
36
+ if(bits[KK])
37
+ code = KK;
38
+ else code = code;
39
+ end
40
+ end
41
+ end
42
+ endgenerate
43
+
44
+ endmodule : bits_decode_nc
45
+
46
+ module bits_decode #(
47
+ parameter NUM = 16,
48
+ parameter NSIZE = $clog2(NUM),
49
+ parameter MODE = "H" //Hight BIT first
50
+ )(
51
+ input clock,
52
+ input rst_n,
53
+ input [NUM-1:0] bits,
54
+ output logic [NSIZE-1:0] code
55
+ );
56
+
57
+ logic [NSIZE-1:0] tmp;
58
+
59
+ bits_decode_nc #(
60
+ .NUM (NUM ),
61
+ .MODE (MODE ) //Hight BIT first
62
+ )bits_decode_nc_inst(
63
+ /* input [NUM-1:0] */ .bits (bits ),
64
+ /* output logic [NSIZE-1:0] */ .code (tmp )
65
+ );
66
+
67
+ always@(posedge clock,negedge rst_n)
68
+ if(~rst_n) code <= '0;
69
+ else code <= tmp;
70
+
71
+ endmodule:bits_decode
@@ -0,0 +1,24 @@
1
+
2
+ sm = SdlModule.new(name:"bits_decode_nc_verb")
3
+ sm.path = File.expand_path(__FILE__)
4
+ sm.real_sv_path = File.join(File.expand_path(__dir__),"#{File.basename(__FILE__,'.rb').sub(/_sdl/,'')}.sv")
5
+ sm.Parameter("NUM",16)
6
+ sm.Parameter("NSIZE",NqString.new('$clog2(NUM)'))
7
+ sm.Parameter("MODE","H")
8
+ sm.Input("origin_bits",dsize:sm.NUM)
9
+ sm.Output("code",dsize:sm.NSIZE)
10
+ sm.origin_sv = true
11
+
12
+
13
+
14
+ sm = SdlModule.new(name:"bits_decode_verb")
15
+ sm.path = File.expand_path(__FILE__)
16
+ sm.real_sv_path = File.join(File.expand_path(__dir__),"#{File.basename(__FILE__,'.rb').sub(/_sdl/,'')}.sv")
17
+ sm.Parameter("NUM",16)
18
+ sm.Parameter("NSIZE",NqString.new('$clog2(NUM)'))
19
+ sm.Parameter("MODE","H")
20
+ sm.Input 'clock'
21
+ sm.Input 'rst_n'
22
+ sm.Input("origin_bits",dsize:sm.NUM)
23
+ sm.Output("code",dsize:sm.NSIZE)
24
+ sm.origin_sv = true
@@ -0,0 +1,43 @@
1
+ /**********************************************
2
+ ______________ ______________
3
+ ______________ \ /\ /|\ /| ______________
4
+ ______________ \/ \/ | \/ | ______________
5
+ descript:
6
+ author : Young
7
+ Version:
8
+ creaded: 2015/5/14 14:37:22
9
+ madified:
10
+ ***********************************************/
11
+ `timescale 1ns/1ps
12
+ module broaden #(
13
+ parameter PHASE = "POSITIVE", //POSITIVE NEGATIVE
14
+ parameter LEN = 4
15
+ )(
16
+ input clk,
17
+ input rst_n,
18
+ input d,
19
+ output q
20
+ );
21
+
22
+
23
+ reg [LEN-1:0] dq;
24
+ reg q_reg;
25
+ always@(posedge clk/*,negedge rst_n*/)
26
+ if(~rst_n)
27
+ if(PHASE == "POSITIVE")
28
+ dq <= {LEN{1'b0}};
29
+ else dq <= {LEN{1'b1}};
30
+ else dq <= {dq[LEN-2:0],d};
31
+
32
+ always@(posedge clk/*,negedge rst_n*/)
33
+ if(PHASE == "POSITIVE")
34
+ if(~rst_n) q_reg <= 1'b0;
35
+ else q_reg <= |dq;
36
+ else if(PHASE == "NEGATIVE")
37
+ if(~rst_n) q_reg <= 1'b1;
38
+ else q_reg <= &dq;
39
+
40
+
41
+ assign q = q_reg;
42
+
43
+ endmodule
@@ -0,0 +1,47 @@
1
+ /**********************************************
2
+ ______________ ______________
3
+ ______________ \ /\ /|\ /| ______________
4
+ ______________ \/ \/ | \/ | ______________
5
+ descript:
6
+ author : Young
7
+ Version:
8
+ creaded: 2015/5/14 14:52:00
9
+ madified:
10
+ ***********************************************/
11
+ `timescale 1ns/1ps
12
+ module broaden_and_cross_clk #(
13
+ parameter PHASE = "POSITIVE", //POSITIVE NEGATIVE
14
+ parameter LEN = 4,
15
+ parameter LAT = 2
16
+ )(
17
+ input rclk,
18
+ input rd_rst_n,
19
+ input wclk,
20
+ input wr_rst_n,
21
+ input d,
22
+ output q
23
+ );
24
+
25
+ wire qq;
26
+
27
+ broaden #(
28
+ .PHASE (PHASE),
29
+ .LEN (LEN) //delay = LEN + 1
30
+ )broaden_inst(
31
+ wclk,
32
+ wr_rst_n,
33
+ d,
34
+ qq
35
+ );
36
+
37
+ cross_clk_sync #(
38
+ .DSIZE (1),
39
+ .LAT (LAT)
40
+ )cross_clk_sync_false_path(
41
+ rclk,
42
+ rd_rst_n,
43
+ qq,
44
+ q
45
+ );
46
+
47
+ endmodule
@@ -0,0 +1,39 @@
1
+ /**********************************************
2
+ ______________ ______________
3
+ ______________ \ /\ /|\ /| ______________
4
+ ______________ \/ \/ | \/ | ______________
5
+ descript:
6
+ author : Young
7
+ Version: VERA.0.1 : 2015/10/30 10:57:22
8
+ xxxxx = xxxx_{|x12}
9
+ creaded: 2015/7/23 13:56:28
10
+ madified:2015/10/30 10:57:18
11
+ ***********************************************/
12
+ `timescale 1ns/1ps
13
+ module ceiling #(
14
+ parameter DSIZE = 16,
15
+ parameter CSIZE = 4, //must smaller than DSIZE
16
+ parameter OSIZE = 8, //must not bigger than DSIZE-CSIZE
17
+ parameter SEQUENTIAL = "TRUE"
18
+ )(
19
+ input clock ,
20
+ input [DSIZE-1:0] indata ,
21
+ output[OSIZE-1:0] outdata
22
+ );
23
+
24
+
25
+ reg [OSIZE-1:0] result = {OSIZE{1'b0}};
26
+ wire[OSIZE-1:0] cm_result;
27
+ wire carry_bit;
28
+ // assign carry_bit = (DSIZE>(CSIZE+OSIZE))? indata[DSIZE-1-CSIZE-OSIZE] : 1'b0;
29
+ assign carry_bit = 1'b0;
30
+
31
+ assign cm_result = (indata[DSIZE-1-:CSIZE] == {CSIZE{1'b0}})? indata[DSIZE-1-CSIZE-:OSIZE]+carry_bit : {OSIZE{1'b1}};
32
+
33
+ always@(posedge clock)
34
+ result <= cm_result;
35
+
36
+
37
+ assign outdata = (SEQUENTIAL == "TRUE")? result : (SEQUENTIAL == "FALSE")? cm_result : {OSIZE{1'b0}};
38
+
39
+ endmodule
@@ -0,0 +1,42 @@
1
+ /**********************************************
2
+ ______________ ______________
3
+ ______________ \ /\ /|\ /| ______________
4
+ ______________ \/ \/ | \/ | ______________
5
+ descript:
6
+ author : Young
7
+ Version: VERA.0.1 : 2015/10/30 10:57:22
8
+ xxxxx = xxxx_{|x12}
9
+ Version: VERA.1.0 : 2016/3/29 下午3:26:26
10
+ add reset signal
11
+ creaded: 2015/7/23 13:56:28
12
+ madified:2015/10/30 10:57:18
13
+ ***********************************************/
14
+ `timescale 1ns/1ps
15
+ module ceiling_A1 #(
16
+ parameter DSIZE = 16,
17
+ parameter CSIZE = 4, //must smaller than DSIZE
18
+ parameter OSIZE = 8, //must not bigger than DSIZE-CSIZE
19
+ parameter SEQUENTIAL = "TRUE"
20
+ )(
21
+ input clock ,
22
+ input rst_n ,
23
+ input [DSIZE-1:0] indata ,
24
+ output[OSIZE-1:0] outdata
25
+ );
26
+
27
+
28
+ reg [OSIZE-1:0] result;
29
+ wire[OSIZE-1:0] cm_result;
30
+ wire carry_bit;
31
+ assign carry_bit = (DSIZE>(CSIZE+OSIZE))? indata[DSIZE-1-CSIZE-OSIZE] : 1'b0;
32
+
33
+ assign cm_result = (indata[DSIZE-1-:CSIZE] == {CSIZE{1'b0}})? indata[DSIZE-1-CSIZE-:OSIZE]+carry_bit : {OSIZE{1'b1}};
34
+
35
+ always@(posedge clock/*,negedge rst_n*/)
36
+ if(~rst_n) result <= {OSIZE{1'b0}};
37
+ else result <= cm_result;
38
+
39
+
40
+ assign outdata = (SEQUENTIAL == "TRUE")? result : (SEQUENTIAL == "FALSE")? cm_result : {OSIZE{1'b0}};
41
+
42
+ endmodule
@@ -0,0 +1,64 @@
1
+ /*******************************************************
2
+ ______________ ___ __ __ ______________
3
+ ______________\ / | |__} | | |\ | ______________
4
+ ______________ \/ | | \ |__| | \| ______________
5
+
6
+ --Module Name:clock_rst
7
+ --Project Name:tmp_avalon
8
+ --Chinese Description:
9
+
10
+ --English Description:
11
+
12
+ --Version:
13
+ --Data modified:
14
+ --author:
15
+ --E-mail: wumingyang@vtron.com
16
+ --Data created:2013/12/18 15:12:37
17
+ ________________________________________________________
18
+ ********************************************************/
19
+ `timescale 1ns/1ps
20
+ module clock_rst(
21
+ output bit clock,
22
+ output bit rst
23
+ );
24
+
25
+ parameter bit ACTIVE = 1;
26
+
27
+ int clk_i = 0;
28
+ int rst_i = 0;
29
+ longint period_cnt = 0;
30
+ bit clk_pause = 1;
31
+ int rst_hold = 10;
32
+ real clk_period = 5;
33
+
34
+ task run(
35
+ input int reset_hold = 10,
36
+ input real period = 5,
37
+ input longint period_count = 0
38
+ );
39
+ begin
40
+ clk_pause = 1;
41
+ clk_i = 0;
42
+ rst_i = 0;
43
+ rst = ACTIVE;
44
+ rst_hold = reset_hold;
45
+ clk_period = period/2;
46
+ period_cnt = period_count;
47
+ // $stop;
48
+ repeat(3) #(period*3);
49
+ clk_pause = 0;
50
+ repeat(rst_hold) @(posedge clock);
51
+ rst = !ACTIVE;
52
+ end
53
+ endtask
54
+
55
+ always #clk_period begin
56
+ if(clk_pause == 0 && (period_cnt == 0 || clk_i<period_cnt))begin
57
+ clock = ~clock;
58
+ end else begin
59
+ clock = clock;
60
+ end
61
+ end
62
+
63
+
64
+ endmodule