1. 下载源码
下载:
这样不能切版本:
$ git clone --recurse-submodules https://github.com/YosysHQ/yosys.git
或者先切到 0.57版本,在clone 对应版本的 submodule:
$ git clone https://github.com/YosysHQ/yosys.git
$ cd yosys
$ git checkout v0.57
$ git submodule update --init --recursive
2. 编译安装
make config-gcc
mkdir build
cd build/
make -f ../Makefile

安装:
sudo make -f ../Makefile VERBOSE=1

运行:

3. 综合一个module
3.1. 与或非门逻辑综合
aoi.v :
module AOI_5_CA0(
input x_in1, x_in2, x_in3, x_in4, x_in5,
output y_out
);
assign y_out = !((x_in1 && x_in2) || (x_in3 && x_in4 && x_in5));
endmodule
yosys> read -sv aoi.v
yosys> hierarchy -top AOI_5_CA0
yosys> write_rtlil
yosys> proc; opt
yosys> show

3.2. 一个4bit 的移位寄存器 module综合
shiftreg.v
module shiftreg_PA_rev(output reg A, input E, clk, rst);
reg B, C, D;
always @ (posedge clk, posedge rst) begin
if(rst==1'b1)begin A=0; B=0; C=0; D=0; end
else begin
A=B;
B=C;
C = D;
D = E;
end
end
endmodule
综合:
yosys> help help
yosys> read -sv shiftreg.v
yosys> hierarchy -top shiftreg_PA_rev
yosys> write_rtlil
yosys> proc; opt
yosys> show
显示如图:

3.3 综合一个较大官方示例
源文件:fiedler-cooley.v
// borrowed with some modifications from
// http://www.ee.ed.ac.uk/~gerard/Teach/Verilog/manual/Example/lrgeEx2/cooley.html
module up3down5(clock, data_in, up, down, carry_out, borrow_out, count_out, parity_out);
input [8:0] data_in;
input clock, up, down;
output reg [8:0] count_out;
output reg carry_out, borrow_out, parity_out;
reg [9:0] cnt_up, cnt_dn;
reg [8:0] count_nxt;
always @(posedge clock)
begin
cnt_dn = count_out - 3'b 101;
cnt_up = count_out + 2'b 11;
case ({up,down})
2'b 00 : count_nxt = data_in;
2'b 01 : count_nxt = cnt_dn;
2'b 10 : count_nxt = cnt_up;
2'b 11 : count_nxt = count_out;
default : count_nxt = 9'bX;
endcase
parity_out <= ^count_nxt;
carry_out <= up & cnt_up[9];
borrow_out <= down & cnt_dn[9];
count_out <= count_nxt;
end
endmodule
需要在图形桌面上的 terminal 中完成:
yosys> help help
yosys> read -sv tests/simple/fiedler-cooley.v
yosys> hierarchy -top up3down5
yosys> write_rtlil
yosys> proc; opt
yosys> show
yosys> show -format ps -viewer gv
yosys> techmap; opt
yosys> write_verilog synth.v
运行到:yosys> show 显示如下:


运行到 yosys> show -format ps -viewer gv 显示如下,屏幕有点小:

2670

被折叠的 条评论
为什么被折叠?



