mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-06 22:23:23 +00:00
docs: moving code examples
Code now resides in `docs/source/code_examples`. `CHAPTER_Prog` -> `stubnets` `APPNOTE_011_Design_Investigation` -> `selections` and `show` `resources/PRESENTATION_Intro` -> `intro` `resources/PRESENTATION_ExSyn` -> `synth_flow` `resources/PRESENTATION_ExAdv` -> `techmap`, `macc`, and `selections` `resources/PRESENTATION_ExOth` -> `scrambler` and `axis` Note that generated images are not yet configured to build from the new code locations.
This commit is contained in:
parent
3d70867809
commit
dbc38d72cf
119 changed files with 264 additions and 905 deletions
32
docs/source/code_examples/selections/Makefile
Normal file
32
docs/source/code_examples/selections/Makefile
Normal file
|
@ -0,0 +1,32 @@
|
|||
PROGRAM_PREFIX :=
|
||||
|
||||
YOSYS ?= ../../../../$(PROGRAM_PREFIX)yosys
|
||||
|
||||
SUMPROD = sumprod_00 sumprod_01 sumprod_02 sumprod_03 sumprod_04 sumprod_05
|
||||
SUMPROD_DOTS := $(addsuffix .dot,$(SUMPROD))
|
||||
|
||||
MEMDEMO = memdemo_00 memdemo_01
|
||||
MEMDEMO_DOTS := $(addsuffix .dot,$(MEMDEMO))
|
||||
|
||||
SUBMOD = submod_00 submod_01 submod_02 submod_03
|
||||
SUBMOD_DOTS := $(addsuffix .dot,$(SUBMOD))
|
||||
|
||||
all: select.dot $(SUMPROD_DOTS) $(MEMDEMO_DOTS)
|
||||
|
||||
select.dot: select.v select.ys
|
||||
$(YOSYS) select.ys
|
||||
|
||||
$(SUMPROD_DOTS): sumprod.v
|
||||
$(YOSYS) -p 'opt; cd sumprod; select a:sumstuff; show -format dot -prefix sumprod_00' sumprod.v
|
||||
$(YOSYS) -p 'opt; cd sumprod; select a:sumstuff %x; show -format dot -prefix sumprod_01' sumprod.v
|
||||
$(YOSYS) -p 'opt; cd sumprod; select prod; show -format dot -prefix sumprod_02' sumprod.v
|
||||
$(YOSYS) -p 'opt; cd sumprod; select prod %ci; show -format dot -prefix sumprod_03' sumprod.v
|
||||
$(YOSYS) -p 'opt; cd sumprod; select prod %ci2; show -format dot -prefix sumprod_04' sumprod.v
|
||||
$(YOSYS) -p 'opt; cd sumprod; select prod %ci3; show -format dot -prefix sumprod_05' sumprod.v
|
||||
|
||||
$(MEMDEMO_DOTS): memdemo.v
|
||||
$(YOSYS) -p 'proc; opt; memory; opt; cd memdemo; show -format dot -prefix memdemo_00' memdemo.v
|
||||
$(YOSYS) -p 'proc; opt; memory; opt; cd memdemo; show -format dot -prefix memdemo_01 y %ci2:+$dff[Q,D] %ci*:-$mux[S]:-$dff' memdemo.v
|
||||
|
||||
$(SUBMOD_DOTS): submod.ys memdemo.v
|
||||
$(YOSYS) submod.ys
|
8
docs/source/code_examples/selections/foobaraddsub.v
Normal file
8
docs/source/code_examples/selections/foobaraddsub.v
Normal file
|
@ -0,0 +1,8 @@
|
|||
module foobaraddsub(a, b, c, d, fa, fs, ba, bs);
|
||||
input [7:0] a, b, c, d;
|
||||
output [7:0] fa, fs, ba, bs;
|
||||
assign fa = a + (* foo *) b;
|
||||
assign fs = a - (* foo *) b;
|
||||
assign ba = c + (* bar *) d;
|
||||
assign bs = c - (* bar *) d;
|
||||
endmodule
|
19
docs/source/code_examples/selections/memdemo.v
Normal file
19
docs/source/code_examples/selections/memdemo.v
Normal file
|
@ -0,0 +1,19 @@
|
|||
module memdemo(clk, d, y);
|
||||
|
||||
input clk;
|
||||
input [3:0] d;
|
||||
output reg [3:0] y;
|
||||
|
||||
integer i;
|
||||
reg [1:0] s1, s2;
|
||||
reg [3:0] mem [0:3];
|
||||
|
||||
always @(posedge clk) begin
|
||||
for (i = 0; i < 4; i = i+1)
|
||||
mem[i] <= mem[(i+1) % 4] + mem[(i+2) % 4];
|
||||
{ s2, s1 } = d ? { s1, s2 } ^ d : 4'b0;
|
||||
mem[s1] <= d;
|
||||
y <= mem[s2];
|
||||
end
|
||||
|
||||
endmodule
|
15
docs/source/code_examples/selections/select.v
Normal file
15
docs/source/code_examples/selections/select.v
Normal file
|
@ -0,0 +1,15 @@
|
|||
module test(clk, s, a, y);
|
||||
input clk, s;
|
||||
input [15:0] a;
|
||||
output [15:0] y;
|
||||
reg [15:0] b, c;
|
||||
|
||||
always @(posedge clk) begin
|
||||
b <= a;
|
||||
c <= b;
|
||||
end
|
||||
|
||||
wire [15:0] state_a = (a ^ b) + c;
|
||||
wire [15:0] state_b = (a ^ b) - c;
|
||||
assign y = !s ? state_a : state_b;
|
||||
endmodule
|
10
docs/source/code_examples/selections/select.ys
Normal file
10
docs/source/code_examples/selections/select.ys
Normal file
|
@ -0,0 +1,10 @@
|
|||
read_verilog select.v
|
||||
hierarchy -check -top test
|
||||
proc; opt
|
||||
cd test
|
||||
select -set cone_a state_a %ci*:-$dff
|
||||
select -set cone_b state_b %ci*:-$dff
|
||||
select -set cone_ab @cone_a @cone_b %i
|
||||
show -prefix select -format dot -notitle \
|
||||
-color red @cone_ab -color magenta @cone_a \
|
||||
-color blue @cone_b
|
16
docs/source/code_examples/selections/submod.ys
Normal file
16
docs/source/code_examples/selections/submod.ys
Normal file
|
@ -0,0 +1,16 @@
|
|||
read_verilog memdemo.v
|
||||
proc; opt; memory; opt
|
||||
|
||||
cd memdemo
|
||||
select -set outstage y %ci2:+$dff[Q,D] %ci*:-$mux[S]:-$dff
|
||||
select -set selstage y %ci2:+$dff[Q,D] %ci*:-$dff @outstage %d
|
||||
select -set scramble mem* %ci2 %ci*:-$dff mem* %d @selstage %d
|
||||
submod -name scramble @scramble
|
||||
submod -name outstage @outstage
|
||||
submod -name selstage @selstage
|
||||
|
||||
cd ..
|
||||
show -format dot -prefix submod_00 memdemo
|
||||
show -format dot -prefix submod_01 scramble
|
||||
show -format dot -prefix submod_02 outstage
|
||||
show -format dot -prefix submod_03 selstage
|
12
docs/source/code_examples/selections/sumprod.v
Normal file
12
docs/source/code_examples/selections/sumprod.v
Normal file
|
@ -0,0 +1,12 @@
|
|||
module sumprod(a, b, c, sum, prod);
|
||||
|
||||
input [7:0] a, b, c;
|
||||
output [7:0] sum, prod;
|
||||
|
||||
{* sumstuff *}
|
||||
assign sum = a + b + c;
|
||||
{* *}
|
||||
|
||||
assign prod = a * b * c;
|
||||
|
||||
endmodule
|
Loading…
Add table
Add a link
Reference in a new issue