[Serialization] An FPGA-based instance of the Tilde-HDL series-bidirectional shift register

Source: Internet
Author: User

[Serialization] FPGA OpenGL series instances

Two-way shift register of OpenGL

I. Principles

The registers designed for the previous experiment only store data andCode. Sometimes in order to process the data, you need to shift the data in the register to a high or low position with the shift control signal. A register with the shift function is called a shift register.
This experiment is to design a two-way shift register, which can move and output data input by four-bit serial signals. In addition, this register also has an asynchronous clearing end, which is effective at a low level. There is also a signal input for loading data for the preset data, and a signal input for controlling the Left shift or right shift, as shown in Table 1.1.

Table 1.1 bidirectional shift register function

II. Implementation

Enter the OpenGL code in the design file.

 1   'Timescale  1  NS /     1  PS
2
3 Module shiftdata (left_right, load, CLR, CLK, DIN, dout );
4
5 Input left_right;
6 Wire left_right;
7 Input load;
8 Wire load;
9 Input CLR;
10 Wire CLR;
11 Input CLK;
12 Wire CLK;
13 Input [ 3 : 0 ] Din;
14 Wire [ 3 : 0 ] Din;
15
16 Output [ 3 : 0 ] Dout;
17 Wire [ 3 : 0 ] Dout;
18 Reg [ 3 : 0 ] Data_r;
19
20 Assign dout = Data_r;
21
22 Always @ (posedge CLK or posedge CLR or posedge load)
23 Begin
24 If (CLR = 1 )
25 Data_r <= 0 ;
26 Else If (Load)
27 Data_r <= Din;
28 Else Begin
29 If (Left_right)
30 Begin
31 Data_r <= (Data_r < 1 );
32 Data_r [ 0 ] <= 0 ;
33 End
34 Else Begin
35 Data_r <= (Data_r > 1 );
36 Data_r [ 3 ] <= 0 ;
37 End
38 End
39 End
40
41 Endmodule

 

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.