This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8608a6
commit 2e0a055
Showing
3 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* @file | ||
* mux_2_to_1_io.scala | ||
* @author | ||
* Sina Karvandi (sina@hyperdbg.org) | ||
* @brief | ||
* Implementation of MUX 2 to 1 (I/O) | ||
* @details | ||
* @version 0.1 | ||
* @date | ||
* 2024-05-05 | ||
* | ||
* @copyright | ||
* This project is released under the GNU Public License v3. | ||
*/ | ||
package hwdbg.libs.mux | ||
|
||
import chisel3._ | ||
|
||
import hwdbg.configs._ | ||
|
||
class Mux2To1IO( | ||
debug: Boolean = DebuggerConfigurations.ENABLE_DEBUG | ||
) extends Module { | ||
|
||
val io = IO(new Bundle { | ||
|
||
val a = Input(Bool()) | ||
val b = Input(Bool()) | ||
val select = Input(Bool()) | ||
val out = Output(Bool()) | ||
|
||
}) | ||
io.out := io.a & io.select | io.b & (~io.select) | ||
|
||
} | ||
|
||
object Mux2To1IO { | ||
|
||
def apply( | ||
debug: Boolean = DebuggerConfigurations.ENABLE_DEBUG | ||
)( | ||
a: Bool, | ||
b: Bool, | ||
select: Bool | ||
): (Bool) = { | ||
|
||
val mux2To1IO = Module( | ||
new Mux2To1IO( | ||
debug | ||
) | ||
) | ||
|
||
val out = Wire(Bool()) | ||
|
||
// | ||
// Configure the input signals | ||
// | ||
mux2To1IO.io.a := a | ||
mux2To1IO.io.b := b | ||
mux2To1IO.io.select := select | ||
|
||
// | ||
// Configure the output signals | ||
// | ||
out := mux2To1IO.io.out | ||
|
||
// | ||
// Return the output result | ||
// | ||
out | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters