STAR-future commited on
Commit
ce57c19
·
verified ·
1 Parent(s): 2d66860

add chips/yosys (part 2)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. chips/yosys/docs/source/code_examples/macc/macc_xilinx_wrap_map.v +89 -0
  2. chips/yosys/docs/source/code_examples/macc/macc_xilinx_xmap.v +10 -0
  3. chips/yosys/docs/source/code_examples/macro_commands/fsm.ys +27 -0
  4. chips/yosys/docs/source/code_examples/macro_commands/memory.ys +15 -0
  5. chips/yosys/docs/source/code_examples/macro_commands/opt.ys +15 -0
  6. chips/yosys/docs/source/code_examples/macro_commands/prep.ys +26 -0
  7. chips/yosys/docs/source/code_examples/macro_commands/proc.ys +14 -0
  8. chips/yosys/docs/source/code_examples/macro_commands/synth_ice40.ys +90 -0
  9. chips/yosys/docs/source/code_examples/opt/Makefile +18 -0
  10. chips/yosys/docs/source/code_examples/opt/opt_expr.ys +17 -0
  11. chips/yosys/docs/source/code_examples/opt/opt_merge.ys +17 -0
  12. chips/yosys/docs/source/code_examples/opt/opt_muxtree.ys +16 -0
  13. chips/yosys/docs/source/code_examples/opt/opt_share.ys +17 -0
  14. chips/yosys/docs/source/code_examples/primetest.v +4 -0
  15. chips/yosys/docs/source/code_examples/pyosys/pass.py +37 -0
  16. chips/yosys/docs/source/code_examples/pyosys/simple_database.py +51 -0
  17. chips/yosys/docs/source/code_examples/scrambler/Makefile +13 -0
  18. chips/yosys/docs/source/code_examples/scrambler/scrambler.v +14 -0
  19. chips/yosys/docs/source/code_examples/scrambler/scrambler.ys +21 -0
  20. chips/yosys/docs/source/code_examples/selections/Makefile +32 -0
  21. chips/yosys/docs/source/code_examples/selections/foobaraddsub.v +8 -0
  22. chips/yosys/docs/source/code_examples/selections/memdemo.v +19 -0
  23. chips/yosys/docs/source/code_examples/selections/memdemo.ys +10 -0
  24. chips/yosys/docs/source/code_examples/selections/select.v +15 -0
  25. chips/yosys/docs/source/code_examples/selections/select.ys +10 -0
  26. chips/yosys/docs/source/code_examples/selections/submod.ys +16 -0
  27. chips/yosys/docs/source/code_examples/selections/sumprod.v +12 -0
  28. chips/yosys/docs/source/code_examples/selections/sumprod.ys +13 -0
  29. chips/yosys/docs/source/code_examples/show/Makefile +29 -0
  30. chips/yosys/docs/source/code_examples/show/cmos.v +3 -0
  31. chips/yosys/docs/source/code_examples/show/cmos.ys +17 -0
  32. chips/yosys/docs/source/code_examples/show/example.v +6 -0
  33. chips/yosys/docs/source/code_examples/show/example.ys +6 -0
  34. chips/yosys/docs/source/code_examples/show/example_lscd.ys +8 -0
  35. chips/yosys/docs/source/code_examples/show/example_show.ys +6 -0
  36. chips/yosys/docs/source/code_examples/show/splice.v +11 -0
  37. chips/yosys/docs/source/code_examples/stubnets/.gitignore +3 -0
  38. chips/yosys/docs/source/code_examples/stubnets/Makefile +20 -0
  39. chips/yosys/docs/source/code_examples/stubnets/stubnets.cc +130 -0
  40. chips/yosys/docs/source/code_examples/stubnets/test.v +8 -0
  41. chips/yosys/docs/source/code_examples/synth_flow/Makefile +19 -0
  42. chips/yosys/docs/source/code_examples/synth_flow/memory_01.v +9 -0
  43. chips/yosys/docs/source/code_examples/synth_flow/memory_01.ys +3 -0
  44. chips/yosys/docs/source/code_examples/synth_flow/memory_02.v +27 -0
  45. chips/yosys/docs/source/code_examples/synth_flow/memory_02.ys +4 -0
  46. chips/yosys/docs/source/code_examples/synth_flow/proc_01.v +7 -0
  47. chips/yosys/docs/source/code_examples/synth_flow/proc_01.ys +3 -0
  48. chips/yosys/docs/source/code_examples/synth_flow/proc_02.v +8 -0
  49. chips/yosys/docs/source/code_examples/synth_flow/proc_02.ys +3 -0
  50. chips/yosys/docs/source/code_examples/synth_flow/proc_03.v +10 -0
chips/yosys/docs/source/code_examples/macc/macc_xilinx_wrap_map.v ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (* techmap_celltype = "$mul" *)
2
+ module mul_wrap (A, B, Y);
3
+
4
+ parameter A_SIGNED = 0;
5
+ parameter B_SIGNED = 0;
6
+ parameter A_WIDTH = 1;
7
+ parameter B_WIDTH = 1;
8
+ parameter Y_WIDTH = 1;
9
+
10
+ input [A_WIDTH-1:0] A;
11
+ input [B_WIDTH-1:0] B;
12
+ output [Y_WIDTH-1:0] Y;
13
+
14
+ wire [17:0] A_18 = A;
15
+ wire [24:0] B_25 = B;
16
+ wire [47:0] Y_48;
17
+ assign Y = Y_48;
18
+
19
+ wire [1023:0] _TECHMAP_DO_ = "proc; clean";
20
+
21
+ reg _TECHMAP_FAIL_;
22
+ initial begin
23
+ _TECHMAP_FAIL_ <= 0;
24
+ if (A_SIGNED || B_SIGNED)
25
+ _TECHMAP_FAIL_ <= 1;
26
+ if (A_WIDTH < 4 || B_WIDTH < 4)
27
+ _TECHMAP_FAIL_ <= 1;
28
+ if (A_WIDTH > 18 || B_WIDTH > 25)
29
+ _TECHMAP_FAIL_ <= 1;
30
+ if (A_WIDTH*B_WIDTH < 100)
31
+ _TECHMAP_FAIL_ <= 1;
32
+ end
33
+
34
+ \$__mul_wrapper #(
35
+ .A_SIGNED(A_SIGNED),
36
+ .B_SIGNED(B_SIGNED),
37
+ .A_WIDTH(A_WIDTH),
38
+ .B_WIDTH(B_WIDTH),
39
+ .Y_WIDTH(Y_WIDTH)
40
+ ) _TECHMAP_REPLACE_ (
41
+ .A(A_18),
42
+ .B(B_25),
43
+ .Y(Y_48)
44
+ );
45
+
46
+ endmodule
47
+
48
+ (* techmap_celltype = "$add" *)
49
+ module add_wrap (A, B, Y);
50
+
51
+ parameter A_SIGNED = 0;
52
+ parameter B_SIGNED = 0;
53
+ parameter A_WIDTH = 1;
54
+ parameter B_WIDTH = 1;
55
+ parameter Y_WIDTH = 1;
56
+
57
+ input [A_WIDTH-1:0] A;
58
+ input [B_WIDTH-1:0] B;
59
+ output [Y_WIDTH-1:0] Y;
60
+
61
+ wire [47:0] A_48 = A;
62
+ wire [47:0] B_48 = B;
63
+ wire [47:0] Y_48;
64
+ assign Y = Y_48;
65
+
66
+ wire [1023:0] _TECHMAP_DO_ = "proc; clean";
67
+
68
+ reg _TECHMAP_FAIL_;
69
+ initial begin
70
+ _TECHMAP_FAIL_ <= 0;
71
+ if (A_SIGNED || B_SIGNED)
72
+ _TECHMAP_FAIL_ <= 1;
73
+ if (A_WIDTH < 10 && B_WIDTH < 10)
74
+ _TECHMAP_FAIL_ <= 1;
75
+ end
76
+
77
+ \$__add_wrapper #(
78
+ .A_SIGNED(A_SIGNED),
79
+ .B_SIGNED(B_SIGNED),
80
+ .A_WIDTH(A_WIDTH),
81
+ .B_WIDTH(B_WIDTH),
82
+ .Y_WIDTH(Y_WIDTH)
83
+ ) _TECHMAP_REPLACE_ (
84
+ .A(A_48),
85
+ .B(B_48),
86
+ .Y(Y_48)
87
+ );
88
+
89
+ endmodule
chips/yosys/docs/source/code_examples/macc/macc_xilinx_xmap.v ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ module DSP48_MACC (a, b, c, y);
2
+
3
+ input [17:0] a;
4
+ input [24:0] b;
5
+ input [47:0] c;
6
+ output [47:0] y;
7
+
8
+ assign y = a*b + c;
9
+
10
+ endmodule
chips/yosys/docs/source/code_examples/macro_commands/fsm.ys ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #start:It also calls opt_clean as needed:
2
+ #end:Options:
3
+ # Identify and extract FSMs:
4
+ fsm_detect
5
+ fsm_extract
6
+
7
+ # Basic optimizations:
8
+ fsm_opt
9
+ opt_clean
10
+ fsm_opt
11
+
12
+ # Expanding to nearby gate-logic (if called with -expand):
13
+ fsm_expand
14
+ opt_clean
15
+ fsm_opt
16
+
17
+ # Re-code FSM states (unless called with -norecode):
18
+ fsm_recode
19
+
20
+ # Print information about FSMs:
21
+ fsm_info
22
+
23
+ # Export FSMs in KISS2 file format (if called with -export):
24
+ fsm_export
25
+
26
+ # Map FSMs to RTL cells (unless called with -nomap):
27
+ fsm_map
chips/yosys/docs/source/code_examples/macro_commands/memory.ys ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #start:passes in a useful order:
2
+ #end:This converts memories to word-wide DFFs and address decoders
3
+ opt_mem
4
+ opt_mem_priority
5
+ opt_mem_feedback
6
+ memory_bmux2rom
7
+ memory_dff
8
+ opt_clean
9
+ memory_share
10
+ opt_mem_widen
11
+ memory_memx (when called with -memx)
12
+ opt_clean
13
+ memory_collect
14
+ memory_bram -rules <bram_rules> (when called with -bram)
15
+ memory_map (skipped if called with -nomap)
chips/yosys/docs/source/code_examples/macro_commands/opt.ys ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #start: passes in the following order:
2
+ #end: When called with -fast
3
+ opt_expr
4
+ opt_merge -nomux
5
+
6
+ do
7
+ opt_muxtree
8
+ opt_reduce
9
+ opt_merge
10
+ opt_share (-full only)
11
+ opt_dff (except when called with -noff)
12
+ opt_hier (-hier only)
13
+ opt_clean
14
+ opt_expr
15
+ while <changed design>
chips/yosys/docs/source/code_examples/macro_commands/prep.ys ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #start:The following commands are executed by this synthesis command:
2
+ #end:$
3
+ begin:
4
+ hierarchy -check [-top <top> | -auto-top]
5
+
6
+ coarse:
7
+ optbarriers (if -barriers)
8
+ proc [-ifx]
9
+ check
10
+ flatten [-barriers] (if -flatten)
11
+ future
12
+ opt_expr -keepdc
13
+ check
14
+ opt_clean
15
+ opt -noff -keepdc
16
+ wreduce -keepdc [-memx]
17
+ memory_dff (if -rdff)
18
+ memory_memx (if -memx)
19
+ opt_clean
20
+ memory_collect
21
+ opt -noff -keepdc -fast
22
+ sort
23
+
24
+ check:
25
+ stat
26
+ check
chips/yosys/docs/source/code_examples/macro_commands/proc.ys ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #start: passes in the most common order.
2
+ #end: This replaces the processes
3
+ proc_clean # removes empty branches and processes
4
+ proc_rmdead # removes unreachable branches
5
+ proc_prune
6
+ proc_init # special handling of “initial” blocks
7
+ proc_arst # identifies modeling of async resets
8
+ proc_rom
9
+ proc_mux # converts decision trees to multiplexer networks
10
+ proc_dlatch
11
+ proc_dff # extracts registers from processes
12
+ proc_memwr
13
+ proc_clean # this should remove all the processes, provided all went fine
14
+ opt_expr -keepdc
chips/yosys/docs/source/code_examples/macro_commands/synth_ice40.ys ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #start:The following commands are executed by this synthesis command:
2
+ #end:blif:
3
+ begin:
4
+ read_verilog -D ICE40_HX -lib -specify +/ice40/cells_sim.v
5
+ hierarchy -check -top <top>
6
+ proc
7
+
8
+ flatten:
9
+ check
10
+ flatten
11
+ tribuf -logic
12
+ deminout
13
+
14
+ coarse:
15
+ opt_expr
16
+ check
17
+ opt_clean
18
+ opt -nodffe -nosdff
19
+ fsm
20
+ opt
21
+ wreduce
22
+ peepopt
23
+ opt_clean
24
+ share
25
+ techmap
26
+ opt_expr
27
+ opt_clean
28
+ memory_dff
29
+ alumacc -macc-only
30
+ maccmap -unmap
31
+ opt_clean
32
+ wreduce t:$mul
33
+ techmap
34
+ select a:mul2dsp
35
+ setattr -unset mul2dsp
36
+ opt_expr -fine
37
+ wreduce
38
+ select -clear
39
+ ice40_dsp
40
+ chtype -set $mul t:$__soft_mul
41
+ alumacc
42
+ opt
43
+ memory -nomap [-no-rw-check]
44
+ opt_clean
45
+
46
+ map_ram:
47
+ memory_libmap
48
+ techmap
49
+ ice40_braminit
50
+
51
+ map_ffram:
52
+ opt -fast -mux_undef -undriven -fine
53
+ memory_map
54
+ opt -undriven -fine
55
+
56
+ map_gates:
57
+ ice40_wrapcarry
58
+ techmap
59
+ opt -fast
60
+ ice40_opt
61
+
62
+ map_ffs:
63
+ dfflegalize
64
+ techmap
65
+ opt_expr -mux_undef
66
+ simplemap
67
+ ice40_opt -full
68
+
69
+ map_luts:
70
+ check
71
+ techmap
72
+ simplemap
73
+ techmap
74
+ read_verilog
75
+ abc9
76
+ ice40_wrapcarry -unwrap
77
+ techmap
78
+ clean
79
+ opt_lut -tech ice40
80
+
81
+ map_cells:
82
+ techmap
83
+ clean
84
+
85
+ check:
86
+ autoname
87
+ hierarchy -check
88
+ stat
89
+ check -noinit
90
+ blackbox =A:whitebox
chips/yosys/docs/source/code_examples/opt/Makefile ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ include ../../../common.mk
2
+
3
+ DOT_NAMES = opt_share opt_muxtree opt_merge opt_expr
4
+
5
+ DOTS := $(addsuffix .dot,$(DOT_NAMES))
6
+
7
+ .PHONY: all dots examples
8
+ all: dots examples
9
+ dots: $(DOTS)
10
+ examples:
11
+
12
+ %.dot: %.ys
13
+ @$(YOSYS) $< >/dev/null 2>&1
14
+ @gvpack -u -o $@ $*_full.dot >/dev/null 2>&1
15
+
16
+ .PHONY: clean
17
+ clean:
18
+ @rm -f *.dot
chips/yosys/docs/source/code_examples/opt/opt_expr.ys ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ read_verilog <<EOT
2
+
3
+ module uut(
4
+ input a,
5
+ output y, z
6
+ );
7
+ assign y = a == a;
8
+ assign z = a != a;
9
+ endmodule
10
+
11
+ EOT
12
+
13
+ copy uut after
14
+ opt_expr after
15
+ clean
16
+
17
+ show -format dot -prefix opt_expr_full -notitle -color cornflowerblue uut
chips/yosys/docs/source/code_examples/opt/opt_merge.ys ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ read_verilog <<EOT
2
+
3
+ module uut(
4
+ input [3:0] a, b,
5
+ output [3:0] y, z
6
+ );
7
+ assign y = a + b;
8
+ assign z = b + a;
9
+ endmodule
10
+
11
+ EOT
12
+
13
+ copy uut after
14
+ opt_merge after
15
+ clean
16
+
17
+ show -format dot -prefix opt_merge_full -notitle -color cornflowerblue uut
chips/yosys/docs/source/code_examples/opt/opt_muxtree.ys ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ read_verilog <<EOT
2
+
3
+ module uut(
4
+ input a, b, c, d,
5
+ output y
6
+ );
7
+ assign y = a ? (a ? b : c) : d;
8
+ endmodule
9
+
10
+ EOT
11
+
12
+ copy uut after
13
+ opt_muxtree after
14
+ clean
15
+
16
+ show -format dot -prefix opt_muxtree_full -notitle -color cornflowerblue uut
chips/yosys/docs/source/code_examples/opt/opt_share.ys ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ read_verilog <<EOT
2
+
3
+ module uut(
4
+ input [15:0] a, b,
5
+ input sel,
6
+ output [15:0] res,
7
+ );
8
+ assign res = {sel ? a + b : a - b};
9
+ endmodule
10
+
11
+ EOT
12
+
13
+ copy uut after
14
+ opt_share after
15
+ clean
16
+
17
+ show -format dot -prefix opt_share_full -notitle -color cornflowerblue uut
chips/yosys/docs/source/code_examples/primetest.v ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ module primetest(p, a, b, ok);
2
+ input [15:0] p, a, b;
3
+ output ok = p != a*b || a == 1 || b == 1;
4
+ endmodule
chips/yosys/docs/source/code_examples/pyosys/pass.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pyosys import libyosys as ys
2
+
3
+ class AllEnablePass(ys.Pass):
4
+ def __init__(self):
5
+ super().__init__(
6
+ "all_enable",
7
+ "makes all _DFF_P_ registers require an enable signal"
8
+ )
9
+
10
+ def execute(self, args, design):
11
+ ys.log_header(design, "Adding enable signals\n")
12
+ ys.log_push()
13
+ top_module = design.top_module()
14
+
15
+ if "\\enable" not in top_module.wires_:
16
+ enable_line = top_module.addWire("\\enable")
17
+ enable_line.port_input = True
18
+ top_module.fixup_ports()
19
+
20
+ for cell in top_module.cells_.values():
21
+ if cell.type != "$_DFF_P_":
22
+ continue
23
+ cell.type = "$_DFFE_PP_"
24
+ cell.setPort("\\E", ys.SigSpec(enable_line))
25
+ ys.log_pop()
26
+
27
+ p = AllEnablePass() # register the pass
28
+
29
+ # using the pass
30
+
31
+ design = ys.Design()
32
+ ys.run_pass("read_verilog tests/simple/fiedler-cooley.v", design)
33
+ ys.run_pass("hierarchy -check -auto-top", design)
34
+ ys.run_pass("synth", design)
35
+ ys.run_pass("all_enable", design)
36
+ ys.run_pass("write_verilog out.v", design)
37
+ ys.run_pass("synth_ice40 -json out.json", design)
chips/yosys/docs/source/code_examples/pyosys/simple_database.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pyosys import libyosys as ys
2
+
3
+ # loading design
4
+ design = ys.Design()
5
+
6
+ ys.run_pass("read_verilog tests/simple/fiedler-cooley.v", design)
7
+ ys.run_pass("hierarchy -check -auto-top", design)
8
+
9
+ # top module inspection
10
+ top_module = design.top_module()
11
+
12
+ for id, wire in top_module.wires_.items():
13
+ if not wire.port_input and not wire.port_output:
14
+ continue
15
+ description = "input" if wire.port_input else "output"
16
+ description += " " + wire.name.str()
17
+ if wire.width != 1:
18
+ frm = wire.start_offset
19
+ to = wire.start_offset + wire.width
20
+ if wire.upto:
21
+ to, frm = frm, to
22
+ description += f" [{to}:{frm}]"
23
+ print(description)
24
+
25
+ # synth
26
+
27
+ ys.run_pass("synth", design)
28
+
29
+ # adding the enable line
30
+
31
+ enable_line = top_module.addWire("\\enable")
32
+ enable_line.port_input = True
33
+ top_module.fixup_ports()
34
+
35
+ # hooking the enable line to the internal dff cells
36
+
37
+ for cell in top_module.cells_.values():
38
+ if cell.type != "$_DFF_P_":
39
+ continue
40
+ cell.type = "$_DFFE_PP_"
41
+ cell.setPort("\\E", ys.SigSpec(enable_line))
42
+
43
+ # run check
44
+
45
+ top_module.check()
46
+ ys.run_pass("stat", design)
47
+
48
+ # write outputs
49
+
50
+ ys.run_pass("write_verilog out.v", design)
51
+ ys.run_pass("synth_ice40 -json out.json", design)
chips/yosys/docs/source/code_examples/scrambler/Makefile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ include ../../../common.mk
2
+
3
+ .PHONY: all dots examples
4
+ all: dots examples
5
+ dots: scrambler_p01.dot scrambler_p02.dot
6
+ examples:
7
+
8
+ scrambler_p01.dot scrambler_p02.dot: scrambler.ys scrambler.v
9
+ @$(YOSYS) scrambler.ys >/dev/null 2>&1
10
+
11
+ .PHONY: clean
12
+ clean:
13
+ @rm -f *.dot
chips/yosys/docs/source/code_examples/scrambler/scrambler.v ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module scrambler(
2
+ input clk, rst, in_bit,
3
+ output reg out_bit
4
+ );
5
+ reg [31:0] xs;
6
+ always @(posedge clk) begin
7
+ if (rst)
8
+ xs = 1;
9
+ xs = xs ^ (xs << 13);
10
+ xs = xs ^ (xs >> 17);
11
+ xs = xs ^ (xs << 5);
12
+ out_bit <= in_bit ^ xs[0];
13
+ end
14
+ endmodule
chips/yosys/docs/source/code_examples/scrambler/scrambler.ys ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ read_verilog scrambler.v
2
+
3
+ hierarchy; proc;;
4
+
5
+ cd scrambler
6
+ submod -name xorshift32 xs %c %ci %D %c %ci:+[D] %D %ci*:-$dff xs %co %ci %d
7
+ cd ..
8
+
9
+ show -prefix scrambler_p01 -format dot -notitle scrambler
10
+ show -prefix scrambler_p02 -format dot -notitle xorshift32
11
+
12
+ echo on
13
+
14
+ cd xorshift32
15
+ rename n2 in
16
+ rename n1 out
17
+
18
+ eval -set in 1 -show out
19
+ eval -set in 270369 -show out
20
+
21
+ sat -set out 632435482
chips/yosys/docs/source/code_examples/selections/Makefile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ include ../../../common.mk
2
+
3
+ SUMPROD = sumprod_00 sumprod_01 sumprod_02 sumprod_03 sumprod_04 sumprod_05
4
+ SUMPROD_DOTS := $(addsuffix .dot,$(SUMPROD))
5
+
6
+ MEMDEMO = memdemo_00 memdemo_01
7
+ MEMDEMO_DOTS := $(addsuffix .dot,$(MEMDEMO))
8
+
9
+ SUBMOD = submod_00 submod_01 submod_02 submod_03
10
+ SUBMOD_DOTS := $(addsuffix .dot,$(SUBMOD))
11
+
12
+ .PHONY: all dots examples
13
+ all: dots examples
14
+ dots: select.dot $(SUMPROD_DOTS) $(MEMDEMO_DOTS) $(SUBMOD_DOTS)
15
+ examples: sumprod.out
16
+
17
+ select.dot: select.v select.ys
18
+ @$(YOSYS) select.ys >/dev/null 2>&1
19
+
20
+ $(SUMPROD_DOTS) sumprod.out: sumprod.v sumprod.ys
21
+ @$(YOSYS) sumprod.ys >/dev/null 2>&1
22
+
23
+ $(MEMDEMO_DOTS): memdemo.v memdemo.ys
24
+ @$(YOSYS) memdemo.ys >/dev/null 2>&1
25
+
26
+ $(SUBMOD_DOTS): memdemo.v submod.ys
27
+ @$(YOSYS) submod.ys >/dev/null 2>&1
28
+
29
+ .PHONY: clean
30
+ clean:
31
+ @rm -rf *.dot
32
+ @rm -f sumprod.out
chips/yosys/docs/source/code_examples/selections/foobaraddsub.v ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ module foobaraddsub(a, b, c, d, fa, fs, ba, bs);
2
+ input [7:0] a, b, c, d;
3
+ output [7:0] fa, fs, ba, bs;
4
+ assign fa = a + (* foo *) b;
5
+ assign fs = a - (* foo *) b;
6
+ assign ba = c + (* bar *) d;
7
+ assign bs = c - (* bar *) d;
8
+ endmodule
chips/yosys/docs/source/code_examples/selections/memdemo.v ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module memdemo(clk, d, y);
2
+
3
+ input clk;
4
+ input [3:0] d;
5
+ output reg [3:0] y;
6
+
7
+ integer i;
8
+ reg [1:0] s1, s2;
9
+ reg [3:0] mem [0:3];
10
+
11
+ always @(posedge clk) begin
12
+ for (i = 0; i < 4; i = i+1)
13
+ mem[i] <= mem[(i+1) % 4] + mem[(i+2) % 4];
14
+ { s2, s1 } = d ? { s1, s2 } ^ d : 4'b0;
15
+ mem[s1] <= d;
16
+ y <= mem[s2];
17
+ end
18
+
19
+ endmodule
chips/yosys/docs/source/code_examples/selections/memdemo.ys ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ read_verilog memdemo.v
2
+ prep -top memdemo; memory; opt
3
+
4
+ cd memdemo
5
+ show -format dot -prefix memdemo_00
6
+ show -format dot -prefix memdemo_01 y %ci2
7
+ show -format dot -prefix memdemo_02 y %ci5
8
+ show -format dot -prefix memdemo_03 y %ci5:-$mux[S]
9
+ show -format dot -prefix memdemo_04 y %ci*:-[CLK,S]:+$dff,$mux
10
+ show -format dot -prefix memdemo_05 y %ci2:+$dff[Q,D] %ci*:-$mux[S]:-$dff
chips/yosys/docs/source/code_examples/selections/select.v ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module test(clk, s, a, y);
2
+ input clk, s;
3
+ input [15:0] a;
4
+ output [15:0] y;
5
+ reg [15:0] b, c;
6
+
7
+ always @(posedge clk) begin
8
+ b <= a;
9
+ c <= b;
10
+ end
11
+
12
+ wire [15:0] state_a = (a ^ b) + c;
13
+ wire [15:0] state_b = (a ^ b) - c;
14
+ assign y = !s ? state_a : state_b;
15
+ endmodule
chips/yosys/docs/source/code_examples/selections/select.ys ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ read_verilog select.v
2
+ prep -top test
3
+
4
+ cd test
5
+ select -set cone_a state_a %ci*:-$dff
6
+ select -set cone_b state_b %ci*:-$dff
7
+ select -set cone_ab @cone_a @cone_b %i
8
+ show -prefix select -format dot -notitle \
9
+ -color red @cone_ab -color magenta @cone_a \
10
+ -color blue @cone_b
chips/yosys/docs/source/code_examples/selections/submod.ys ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ read_verilog memdemo.v
2
+ prep -top memdemo; memory; opt
3
+
4
+ cd memdemo
5
+ select -set outstage y %ci2:+$dff[Q,D] %ci*:-$mux[S]:-$dff
6
+ select -set selstage y %ci2:+$dff[Q,D] %ci*:-$dff @outstage %d
7
+ select -set scramble mem* %ci2 %ci*:-$dff mem* %d @selstage %d
8
+ submod -name scramble @scramble
9
+ submod -name outstage @outstage
10
+ submod -name selstage @selstage
11
+
12
+ cd ..
13
+ show -format dot -prefix submod_00 memdemo
14
+ show -format dot -prefix submod_01 scramble
15
+ show -format dot -prefix submod_02 outstage
16
+ show -format dot -prefix submod_03 selstage
chips/yosys/docs/source/code_examples/selections/sumprod.v ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module sumprod(a, b, c, sum, prod);
2
+
3
+ input [7:0] a, b, c;
4
+ output [7:0] sum, prod;
5
+
6
+ {* sumstuff *}
7
+ assign sum = a + b + c;
8
+ {* *}
9
+
10
+ assign prod = a * b * c;
11
+
12
+ endmodule
chips/yosys/docs/source/code_examples/selections/sumprod.ys ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ read_verilog sumprod.v
2
+ prep -top sumprod
3
+ cd sumprod
4
+
5
+ show -format dot -prefix sumprod_00 a:sumstuff
6
+ show -format dot -prefix sumprod_01 a:sumstuff %x
7
+ show -format dot -prefix sumprod_02 prod
8
+ show -format dot -prefix sumprod_03 prod %ci
9
+ show -format dot -prefix sumprod_04 prod %ci2
10
+ show -format dot -prefix sumprod_05 prod %ci3
11
+
12
+ dump -o sumprod.out prod %ci
13
+ dump -a sumprod.out prod %ci2
chips/yosys/docs/source/code_examples/show/Makefile ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ include ../../../common.mk
2
+
3
+ EXAMPLE = example_first example_second example_third
4
+ EXAMPLE_DOTS := $(addsuffix .dot,$(EXAMPLE))
5
+
6
+ CMOS = cmos_00 cmos_01
7
+ CMOS_DOTS := $(addsuffix .dot,$(CMOS))
8
+
9
+ .PHONY: all dots examples
10
+ all: dots examples
11
+ dots: splice.dot $(EXAMPLE_DOTS) $(CMOS_DOTS)
12
+ examples: example.out
13
+
14
+ splice.dot: splice.v
15
+ @$(YOSYS) -p 'prep -top splice_demo; show -format dot -prefix splice' splice.v >/dev/null 2>&1
16
+
17
+ $(EXAMPLE_DOTS): example.v example.ys
18
+ @$(YOSYS) example.ys >/dev/null 2>&1
19
+
20
+ example.out: example_lscd.ys example.v
21
+ @$(YOSYS) $< -l $@ -Q -T >/dev/null 2>&1
22
+
23
+ $(CMOS_DOTS): cmos.v cmos.ys
24
+ @$(YOSYS) cmos.ys >/dev/null 2>&1
25
+
26
+ .PHONY: clean
27
+ clean:
28
+ @rm -rf *.dot
29
+ @rm -f example.out
chips/yosys/docs/source/code_examples/show/cmos.v ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ module cmos_demo(input a, b, output [1:0] y);
2
+ assign y = a + b;
3
+ endmodule
chips/yosys/docs/source/code_examples/show/cmos.ys ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # pitfall
2
+ read_verilog cmos.v
3
+ prep -top cmos_demo
4
+ techmap
5
+ abc -liberty ../intro/mycells.lib;;
6
+ show -format dot -prefix cmos_00
7
+
8
+ # reset
9
+ design -reset
10
+
11
+ # fixed output
12
+ read_verilog cmos.v
13
+ prep -top cmos_demo
14
+ techmap
15
+ splitnets -ports
16
+ abc -liberty ../intro/mycells.lib;;
17
+ show -lib ../intro/mycells.v -format dot -prefix cmos_01
chips/yosys/docs/source/code_examples/show/example.v ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ module example(input clk, a, b, c,
2
+ output reg [1:0] y);
3
+ always @(posedge clk)
4
+ if (c)
5
+ y <= c ? a + b : 2'd0;
6
+ endmodule
chips/yosys/docs/source/code_examples/show/example.ys ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ read_verilog example.v
2
+ show -format dot -prefix example_first
3
+ proc
4
+ show -format dot -prefix example_second
5
+ opt
6
+ show -format dot -prefix example_third
chips/yosys/docs/source/code_examples/show/example_lscd.ys ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ read_verilog example.v
2
+ echo on
3
+ ls
4
+ cd example
5
+ ls
6
+ dump $2
7
+ cd ..
8
+ echo off
chips/yosys/docs/source/code_examples/show/example_show.ys ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ read_verilog example.v
2
+ show -pause # first
3
+ proc
4
+ show -pause # second
5
+ opt
6
+ show -pause # third
chips/yosys/docs/source/code_examples/show/splice.v ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module splice_demo(a, b, c, d, e, f, x, y);
2
+
3
+ input [1:0] a, b, c, d, e, f;
4
+ output [1:0] x;
5
+ assign x = {a[0], a[1]};
6
+
7
+ output [11:0] y;
8
+ assign {y[11:4], y[1:0], y[3:2]} =
9
+ {a, b, -{c, d}, ~{e, f}};
10
+
11
+ endmodule
chips/yosys/docs/source/code_examples/stubnets/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ stubnets.so
2
+ stubnets.d
3
+ *.log
chips/yosys/docs/source/code_examples/stubnets/Makefile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ include ../../../common.mk
2
+
3
+ .PHONY: all dots examples
4
+ all: dots examples
5
+ dots:
6
+ examples: test
7
+
8
+ .PHONY: test
9
+ test: stubnets.so
10
+ @$(YOSYS) -ql test1.log -m ./stubnets.so test.v -p "stubnets" >/dev/null 2>&1
11
+ @$(YOSYS) -ql test2.log -m ./stubnets.so test.v -p "opt; stubnets" >/dev/null 2>&1
12
+ @$(YOSYS) -ql test3.log -m ./stubnets.so test.v -p "techmap; opt; stubnets -report_bits" >/dev/null 2>&1
13
+
14
+ stubnets.so: stubnets.cc
15
+ @$(YOSYS_CONFIG) --exec --cxx --cxxflags --ldflags -o $@ -shared $^ --ldlibs >/dev/null 2>&1
16
+
17
+ .PHONY: clean
18
+ clean:
19
+ @rm -f test1.log test2.log test3.log
20
+ @rm -f stubnets.so stubnets.d
chips/yosys/docs/source/code_examples/stubnets/stubnets.cc ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This is free and unencumbered software released into the public domain.
2
+ //
3
+ // Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ // distribute this software, either in source code form or as a compiled
5
+ // binary, for any purpose, commercial or non-commercial, and by any
6
+ // means.
7
+
8
+ #include "kernel/yosys.h"
9
+ #include "kernel/sigtools.h"
10
+
11
+ #include <string>
12
+ #include <map>
13
+ #include <set>
14
+
15
+ USING_YOSYS_NAMESPACE
16
+ PRIVATE_NAMESPACE_BEGIN
17
+
18
+ // this function is called for each module in the design
19
+ static void find_stub_nets(RTLIL::Design *design, RTLIL::Module *module, bool report_bits)
20
+ {
21
+ // use a SigMap to convert nets to a unique representation
22
+ SigMap sigmap(module);
23
+
24
+ // count how many times a single-bit signal is used
25
+ std::map<RTLIL::SigBit, int> bit_usage_count;
26
+
27
+ // count output lines for this module (needed only for summary output at the end)
28
+ int line_count = 0;
29
+
30
+ log("Looking for stub wires in module %s:\n", module);
31
+
32
+ // For all ports on all cells
33
+ for (auto &cell_iter : module->cells_)
34
+ for (auto &conn : cell_iter.second->connections())
35
+ {
36
+ // Get the signals on the port
37
+ // (use sigmap to get a uniqe signal name)
38
+ RTLIL::SigSpec sig = sigmap(conn.second);
39
+
40
+ // add each bit to bit_usage_count, unless it is a constant
41
+ for (auto &bit : sig)
42
+ if (bit.wire != NULL)
43
+ bit_usage_count[bit]++;
44
+ }
45
+
46
+ // for each wire in the module
47
+ for (auto &wire_iter : module->wires_)
48
+ {
49
+ RTLIL::Wire *wire = wire_iter.second;
50
+
51
+ // .. but only selected wires
52
+ if (!design->selected(module, wire))
53
+ continue;
54
+
55
+ // add +1 usage if this wire actually is a port
56
+ int usage_offset = wire->port_id > 0 ? 1 : 0;
57
+
58
+ // we will record which bits of the (possibly multi-bit) wire are stub signals
59
+ std::set<int> stub_bits;
60
+
61
+ // get a signal description for this wire and split it into separate bits
62
+ RTLIL::SigSpec sig = sigmap(wire);
63
+
64
+ // for each bit (unless it is a constant):
65
+ // check if it is used at least two times and add to stub_bits otherwise
66
+ for (int i = 0; i < GetSize(sig); i++)
67
+ if (sig[i].wire != NULL && (bit_usage_count[sig[i]] + usage_offset) < 2)
68
+ stub_bits.insert(i);
69
+
70
+ // continue if no stub bits found
71
+ if (stub_bits.size() == 0)
72
+ continue;
73
+
74
+ // report stub bits and/or stub wires, don't report single bits
75
+ // if called with report_bits set to false.
76
+ if (GetSize(stub_bits) == GetSize(sig)) {
77
+ log(" found stub wire: %s\n", wire);
78
+ } else {
79
+ if (!report_bits)
80
+ continue;
81
+ std::string bits;
82
+ for (int bit : stub_bits)
83
+ bits += stringf("%s%d", bit == *stub_bits.begin() ? "" : ", ", bit);
84
+ log(" found wire with stub bits: %s [%s]\n", wire, bits);
85
+ }
86
+
87
+ // we have outputted a line, increment summary counter
88
+ line_count++;
89
+ }
90
+
91
+ // report summary
92
+ if (report_bits)
93
+ log(" found %d stub wires or wires with stub bits.\n", line_count);
94
+ else
95
+ log(" found %d stub wires.\n", line_count);
96
+ }
97
+
98
+ // each pass contains a singleton object that is derived from Pass
99
+ struct StubnetsPass : public Pass {
100
+ StubnetsPass() : Pass("stubnets") { }
101
+ void execute(std::vector<std::string> args, RTLIL::Design *design) override
102
+ {
103
+ // variables to mirror information from passed options
104
+ bool report_bits = 0;
105
+
106
+ log_header(design, "Executing STUBNETS pass (find stub nets).\n");
107
+
108
+ // parse options
109
+ size_t argidx;
110
+ for (argidx = 1; argidx < args.size(); argidx++) {
111
+ std::string arg = args[argidx];
112
+ if (arg == "-report_bits") {
113
+ report_bits = true;
114
+ continue;
115
+ }
116
+ break;
117
+ }
118
+
119
+ // handle extra options (e.g. selection)
120
+ extra_args(args, argidx, design);
121
+
122
+ // call find_stub_nets() for each module that is either
123
+ // selected as a whole or contains selected objects.
124
+ for (auto &it : design->modules_)
125
+ if (design->selected_module(it.first))
126
+ find_stub_nets(design, it.second, report_bits);
127
+ }
128
+ } StubnetsPass;
129
+
130
+ PRIVATE_NAMESPACE_END
chips/yosys/docs/source/code_examples/stubnets/test.v ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ module uut(in1, in2, in3, out1, out2);
2
+
3
+ input [8:0] in1, in2, in3;
4
+ output [8:0] out1, out2;
5
+
6
+ assign out1 = in1 + in2 + (in3 >> 4);
7
+
8
+ endmodule
chips/yosys/docs/source/code_examples/synth_flow/Makefile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ include ../../../common.mk
2
+
3
+ DOT_TARGETS += proc_01 proc_02 proc_03
4
+ DOT_TARGETS += memory_01 memory_02
5
+ DOT_TARGETS += techmap_01
6
+
7
+ DOTS = $(addsuffix .dot,$(DOT_TARGETS))
8
+
9
+ .PHONY: all dots examples
10
+ all: dots examples
11
+ dots: $(DOTS)
12
+ examples:
13
+
14
+ %.dot: %.v %.ys
15
+ @$(YOSYS) -p 'script $*.ys; show -notitle -prefix $* -format dot' >/dev/null 2>&1
16
+
17
+ .PHONY: clean
18
+ clean:
19
+ @rm -f *.dot
chips/yosys/docs/source/code_examples/synth_flow/memory_01.v ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ module test(input CLK, ADDR,
2
+ input [7:0] DIN,
3
+ output reg [7:0] DOUT);
4
+ reg [7:0] mem [0:1];
5
+ always @(posedge CLK) begin
6
+ mem[ADDR] <= DIN;
7
+ DOUT <= mem[ADDR];
8
+ end
9
+ endmodule
chips/yosys/docs/source/code_examples/synth_flow/memory_01.ys ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ read_verilog memory_01.v
2
+ hierarchy -check -top test
3
+ proc;; memory; opt
chips/yosys/docs/source/code_examples/synth_flow/memory_02.v ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module test(
2
+ input WR1_CLK, WR2_CLK,
3
+ input WR1_WEN, WR2_WEN,
4
+ input [7:0] WR1_ADDR, WR2_ADDR,
5
+ input [7:0] WR1_DATA, WR2_DATA,
6
+ input RD1_CLK, RD2_CLK,
7
+ input [7:0] RD1_ADDR, RD2_ADDR,
8
+ output reg [7:0] RD1_DATA, RD2_DATA
9
+ );
10
+
11
+ reg [7:0] memory [0:255];
12
+
13
+ always @(posedge WR1_CLK)
14
+ if (WR1_WEN)
15
+ memory[WR1_ADDR] <= WR1_DATA;
16
+
17
+ always @(posedge WR2_CLK)
18
+ if (WR2_WEN)
19
+ memory[WR2_ADDR] <= WR2_DATA;
20
+
21
+ always @(posedge RD1_CLK)
22
+ RD1_DATA <= memory[RD1_ADDR];
23
+
24
+ always @(posedge RD2_CLK)
25
+ RD2_DATA <= memory[RD2_ADDR];
26
+
27
+ endmodule
chips/yosys/docs/source/code_examples/synth_flow/memory_02.ys ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ read_verilog memory_02.v
2
+ hierarchy -check -top test
3
+ proc;; memory -nomap
4
+ opt -mux_undef -mux_bool
chips/yosys/docs/source/code_examples/synth_flow/proc_01.v ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ module test(input D, C, R, output reg Q);
2
+ always @(posedge C, posedge R)
3
+ if (R)
4
+ Q <= 0;
5
+ else
6
+ Q <= D;
7
+ endmodule
chips/yosys/docs/source/code_examples/synth_flow/proc_01.ys ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ read_verilog proc_01.v
2
+ hierarchy -check -top test
3
+ proc;;
chips/yosys/docs/source/code_examples/synth_flow/proc_02.v ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ module test(input D, C, R, RV,
2
+ output reg Q);
3
+ always @(posedge C, posedge R)
4
+ if (R)
5
+ Q <= RV;
6
+ else
7
+ Q <= D;
8
+ endmodule
chips/yosys/docs/source/code_examples/synth_flow/proc_02.ys ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ read_verilog proc_02.v
2
+ hierarchy -check -top test
3
+ proc;;
chips/yosys/docs/source/code_examples/synth_flow/proc_03.v ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ module test(input A, B, C, D, E,
2
+ output reg Y);
3
+ always @* begin
4
+ Y <= A;
5
+ if (B)
6
+ Y <= C;
7
+ if (D)
8
+ Y <= E;
9
+ end
10
+ endmodule