Making a 4-bit ALU from several 1-bit ALUs

前端 未结 2 1437
感情败类
感情败类 2021-01-27 05:56

I\'m trying to combine several 1 bit ALUs into a 4 bit ALU. I am confused about how to actually do this in VHDL. Here is the code for the 1bit ALU that I am using:



        
2条回答
  •  礼貌的吻别
    2021-01-27 06:55

    You can't (easily) string together these 1-bit ALUs into a functional multiple bit version. There is no way to handle the carry in/out needed for your add and subtract modes to work properly (the bitwise and & or should work OK, however).

    Ignoring the carry issue for the moment, you would typically just setup a for generate loop and instantiate multiple copies of your bitwise logic, possibly special casing the first and/or last elements, ie:

    MyLabel : for bitindex in 0 to 3 generate
    begin
      alu_x4 : entity work.alu1
      port map (
        a => input_a(bitindex),
        b => input_b(bitindex),
        m => mode,
        result => result_x4(bitindex) );
    end generate;
    

提交回复
热议问题