📄 paralla to serials.v
字号:
`timescale 1ns/1nsmodule PtoS( //output PR_CLK, PR_DATA, //input CLK, DATA_CS, DATA_LATCH, DATA );output PR_CLK;output PR_DATA;input CLK;input DATA_CS;input DATA_LATCH;input [7:0] DATA;//input 8 bit datawire PR_CLK; //the gate control clkwire PR_DATA;//the serials data to outputreg [1:0] flag = 0;reg [7:0] d; //the memory that store the input datareg [3:0] count = 0;//note: this will be a problem in synthesisassign PR_CLK = ((count >= 0) && (count <= 7) && (DATA_CS))? CLK : 1'b0;assign PR_DATA = (DATA_CS)? d[7] : 1'b0;always @(posedge CLK)begin if(count == 7) begin count <= 0; end if(DATA_CS) begin if(count < 7) begin if(flag == 0) begin count <= 0; flag <= 1; end else count <= count + 1; end if(flag == 1) flag <= 2; end endalways @(posedge DATA_LATCH) d = DATA;always @(posedge PR_CLK)begin if(count == 0) begin if(flag == 1) d <= {d[6:0],1'b0}; else d <= d; end else if(count <= 7) d <= {d[6:0],1'b0};endendmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -