quartus如何将四个输入转换为块中的两个输入?

Posted

技术标签:

【中文标题】quartus如何将四个输入转换为块中的两个输入?【英文标题】:quartus how convert four input to two inputs in block? 【发布时间】:2011-04-17 13:33:04 【问题描述】:

如何将需要 4 个输入的 bloch 实体转换为 2 个输入? http://dl.dropbox.com/u/2879760/sample.PNG 你在这里看到我使用三个相同的多路复用器:(如何只接受 etykieta2 两个输入? 代码:

library ieee;
  use ieee.std_logic_1164.all;
  library work; --domyslnie zawieta moj pakiet

  use work.mux_package.all;

  entity glowny is

            generic(
                n : integer := 4;
                k : integer := 2
            );
            port(
                a, b, c, d,e,f,g,h : in std_logic_vector(n-1 downto 0);
                s : in std_logic_vector(1 downto 0);
                t : in std_logic_vector (1 downto 0);
                y, x, z : out std_logic_vector(n-1 downto 0)
            );
        end glowny;

architecture multiplekser of glowny is

signal xx,yy,zz : std_logic_vector(n-1 downto 0); 

    for etykieta: mux use entity work.mux(arch_mux5);
    for etykieta1: mux use entity work.mux(arch_mux6);
    for etykieta2: mux use entity work.mux(arch_mux3);

    begin

    etykieta:
    mux generic map (n=>n) port map (a=> a, b=>b, c=>c, d=>d,s=>s, y=>xx);

    etykieta1:
    mux generic map (n=>n) port map (a=> e, b=>f, c=>g, d=>h,s=>s,y=>yy);

    etykieta2:
    mux generic map (n=>n) port map (a=> yy , b=>yy, c=> xx, d=>xx, s=>t ,y=>zz);



end multiplekser;

    library ieee;
      use ieee.std_logic_1164.all;
        entity mux is

            generic(
                n : integer := 4
            );
            port(
                a, b, c, d : in std_logic_vector(n-1 downto 0);
                s : in std_logic_vector(1 downto 0);
                y : out std_logic_vector(n-1 downto 0)
            );
        end mux;



      -- przypisanie podstawowe - concurrent signal assigment

      architecture arch_mux1 of mux is

        begin

            y(0) <= (a(0) and not(s(1)) and not(s(0)))
                or (b(0) and not(s(1)) and s(0))
                or (c(0) and s(1) and not(s(0)))
                or (d(0) and s(1) and s(0));

            y(1) <= (a(1) and not(s(1)) and not(s(0)))
                or (b(1) and not(s(1)) and s(0))
                or (c(1) and s(1) and not(s(0)))
                or (d(1) and s(1) and s(0));

            y(2) <= (a(2) and not(s(1)) and not(s(0)))
                or (b(2) and not(s(1)) and s(0))
                or (c(2) and s(1) and not(s(0)))
                or (d(2) and s(1) and s(0));

            y(3) <= (a(3) and not(s(1)) and not(s(0)))
                or (b(3) and not(s(1)) and s(0))
                or (c(3) and s(1) and not(s(0)))
                or (d(3) and s(1) and s(0));

        end arch_mux1;



      -- przypisanie warunkowe - conditional signal assigment
      architecture arch_mux2 of mux is
        begin
            with s select
                y <= a when "00",
                b when "01",
                c when "10",
                d when others;
      end arch_mux2;

      -- przypisanie selektywne - selected signal assigment

      architecture arch_mux3 of mux is
        begin
            y <= a when (s = "00") else
            b when (s = "01") else
            c when (s = "10") else
            d;
      end arch_mux3;

      architecture arch_mux4 of mux is
        begin
            pr_if: process(a,b,c,d,s) --lista czulosci
            begin

                case s is
                    when "00" => y <= a; -- czytamy y :=
                    when "01" => y <= b;
                    when "10" => y <= c;
                    --when "11" => y <= d;
                        y <= (others => '0');
                    when others => y <= d;
                end case;

            end process;

        end arch_mux4;

        architecture arch_mux5 of mux is
        begin
            pr_if: process(a,b,c,d,s) --lista czulosci
            begin

                if s ="00" then
                    y <= a;
                elsif s="01" then
                    y <=b;
                elsif s="10" then
                    y <=c;
                else
                    y <=d;
                end if;
            end process;

        end arch_mux5;

        architecture arch_mux6 of mux is
        begin
            pr_if: process(a,b,c,d,s) --lista czulosci
            begin

                y<=(others=>'0');

                if s ="00" then
                    y <= a;
                end if;

                if s ="01" then
                    y <= b;
                end if;

                if s ="10" then
                    y <= c;
                end if;

--              if s ="11" then
--                  y <= d;
--              end if;

            end process;

        end arch_mux6;

        architecture arch_mux7 of mux is
        begin
            pr_if: process(a,b,c,d,s) --lista czulosci
            begin

                   --w procesie jak najbardziej jest to prawidlowe, tylko warningi sa (LACHE - pamieci)
            if s = "00" then
                y <= a;
            else
                y <=(others => '0');  
            end if;

            if s = "01" then
                y <= b;
            else
                y <=(others => '0');  
            end if;

            if s = "10" then
                y <= c;
            else
                y <=(others => '0');  
            end if;

            if s = "11" then -- zadziala tylko ten if bo jest sekwencyjnie ywkonywane i albo da 'd' albo 0000
                y <= d;
            else
                y <=(others => '0');  
            end if;


            end process;

        end arch_mux7;



     -- configuration conf_mux of mux is
        --for arch_mux6
        --end for;
      --end conf_mux;

【问题讨论】:

首先,应该清楚的是,这段代码只是作为一个教育练习。没有人在这个细节上写(或不应该写)多路复用器,或者在同一个多路复用器的七种不同实现中。也许您应该将您的问题标记为“家庭作业” 看起来您的代码反映了您的框图。你到底想改变什么?你有什么问题? 【参考方案1】:

我怎样才能转换bloch的实体 哪个需要 4 个输入到 2 个输入?

你的意思是让你的输入 ah 和输出 x,y,z 2 位宽而不是 4 位?

只需更改相关的generic,当然可以!

【讨论】:

以上是关于quartus如何将四个输入转换为块中的两个输入?的主要内容,如果未能解决你的问题,请参考以下文章

jquery 动画如何将四个角的方块移动到中间

如何将四个按钮水平和垂直居中?

quartus如何将原理图转成verilog格式

内存分配失败:如何将四个结果集合并到一张表中

多个块中的必填字段

QUARTUS下如何设置CPLD输入管脚为上拉