Compare commits

..

2 commits

Author SHA1 Message Date
Artturin 3afca5b0f9 Remove all trailing spaces
`git grep -I --name-only -z -e '' | xargs -0 sed -i 's/[ \t]\+\(\r\?\)$/\1/'`

Remember to setup your editor so that these are automatically removed :)
2025-04-02 03:04:44 +03:00
Artturin 1c8ebeb238 Add initial flake 2025-04-02 02:59:21 +03:00
9 changed files with 153 additions and 38 deletions

View file

@ -100,7 +100,7 @@ b_all: b_compile b_link b_sim
b_compile: b_compile:
mkdir -p build_b_sim mkdir -p build_b_sim
@echo Compiling for Bluesim ... @echo Compiling for Bluesim ...
bsc -u -sim $(B_SIM_DIRS) $(BSC_COMP_FLAGS) $(BSC_PATHS) -g $(TOPMODULE) $(TOPFILE) bsc -u -sim $(B_SIM_DIRS) $(BSC_COMP_FLAGS) $(BSC_PATHS) -g $(TOPMODULE) $(TOPFILE)
@echo Compiling for Bluesim finished @echo Compiling for Bluesim finished
.PHONY: b_link .PHONY: b_link
@ -142,7 +142,7 @@ v_compile:
.PHONY: v_link .PHONY: v_link
v_link: $(BDPI_OBJ) v_link: $(BDPI_OBJ)
@echo Linking for Verilog sim ... @echo Linking for Verilog sim ...
bsc -e $(TOPMODULE) -verilog -o ./$(V_SIM_EXE) $(V_DIRS) -vsim $(V_SIM) verilog_RTL/$(TOPMODULE).v bsc -e $(TOPMODULE) -verilog -o ./$(V_SIM_EXE) $(V_DIRS) -vsim $(V_SIM) verilog_RTL/$(TOPMODULE).v
@echo Linking for Verilog sim finished @echo Linking for Verilog sim finished
.PHONY: v_sim .PHONY: v_sim

View file

@ -1,7 +1,7 @@
# MannaChip # MannaChip
## Introduction: ## Introduction:
Manna was the miraculous food provided by God requiring no effort on behalf of the Israelites. In a similar vein, the POWER3.0 compliant MannaChip Manna was the miraculous food provided by God requiring no effort on behalf of the Israelites. In a similar vein, the POWER3.0 compliant MannaChip
processor delivers groundbreaking performance, necessitating minimal intervention on the developer's or user's part. processor delivers groundbreaking performance, necessitating minimal intervention on the developer's or user's part.
Just as "man does not live by bread alone, but by every word that proceeds from the mouth of God," this chip thrives on every instruction word you provide. It's not just about raw computational power, but the synergy between user input and hardware optimization. Just as "man does not live by bread alone, but by every word that proceeds from the mouth of God," this chip thrives on every instruction word you provide. It's not just about raw computational power, but the synergy between user input and hardware optimization.
@ -10,7 +10,7 @@ Just as "man does not live by bread alone, but by every word that proceeds from
be found in the ``verilog_RTL/`` folder. be found in the ``verilog_RTL/`` folder.
# Status # Status
Admittedly, not very far. Perhaps one could say we've got the beginnings Admittedly, not very far. Perhaps one could say we've got the beginnings
of what would make for LED and UART controllers. of what would make for LED and UART controllers.
# Dependencies # Dependencies

View file

@ -9,7 +9,7 @@ interface (ClkDivider :: # -> *) hi =
mkClkDivider :: Handle -> Module (ClkDivider hi) mkClkDivider :: Handle -> Module (ClkDivider hi)
mkClkDivider fileHandle = do mkClkDivider fileHandle = do
counter <- mkReg(0 :: UInt (TLog hi)) counter <- mkReg(0 :: UInt (TLog hi))
let hi_value :: UInt (TLog hi) = (fromInteger $ valueOf hi) let hi_value :: UInt (TLog hi) = (fromInteger $ valueOf hi)
let half_hi_value :: UInt (TLog hi) = (fromInteger $ valueOf (TDiv hi 2)) let half_hi_value :: UInt (TLog hi) = (fromInteger $ valueOf (TDiv hi 2))
@ -28,7 +28,7 @@ mkClkDivider fileHandle = do
counter := if (counter == hi_value) counter := if (counter == hi_value)
then 0 then 0
else counter + 1 else counter + 1
return $ return $
interface ClkDivider interface ClkDivider
reset :: Action reset :: Action

View file

@ -1,15 +1,15 @@
package Deserializer( package Deserializer(
mkDeserialize, mkDeserialize,
IDeserializer(..), IDeserializer(..),
State(..)) State(..))
where where
import ClkDivider import ClkDivider
import State import State
interface (IDeserializer :: # -> # -> *) clkFreq baudRate = interface (IDeserializer :: # -> # -> *) clkFreq baudRate =
get :: Bit 8 get :: Bit 8
putBitIn :: (Bit 1) -> Action {-# always_enabled, always_ready #-} putBitIn :: (Bit 1) -> Action {-# always_enabled, always_ready #-}
mkDeserialize :: Handle -> Module (IDeserializer clkFreq baudRate) mkDeserialize :: Handle -> Module (IDeserializer clkFreq baudRate)
@ -35,10 +35,10 @@ mkDeserialize fileHandle = do
ftdiState := ftdiState' ftdiState ftdiState := ftdiState' ftdiState
{-# ASSERT fire when enabled #-} {-# ASSERT fire when enabled #-}
"SAMPLING" : when "SAMPLING" : when
DATA(n) <- ftdiState, DATA(n) <- ftdiState,
n >= 0, n >= 0,
n <= 7, n <= 7,
let sampleTrigger = clkDivider.isHalfCycle let sampleTrigger = clkDivider.isHalfCycle
in sampleTrigger in sampleTrigger
==> ==>
@ -48,6 +48,6 @@ mkDeserialize fileHandle = do
return $ return $
interface IDeserializer interface IDeserializer
{get = shiftReg when (ftdiState == STOP), (clkDivider.isAdvancing) {get = shiftReg when (ftdiState == STOP), (clkDivider.isAdvancing)
;putBitIn bit = ;putBitIn bit =
ftdiRxIn := bit ftdiRxIn := bit
} }

View file

@ -1,7 +1,7 @@
package Serializer( package Serializer(
mkSerialize, mkSerialize,
ISerializer(..), ISerializer(..),
State(..)) State(..))
where where
import ClkDivider import ClkDivider
@ -14,7 +14,7 @@ serialize ftdiState dataReg =
(DATA n) -> dataReg[n:n] (DATA n) -> dataReg[n:n]
_ -> 1'b1 _ -> 1'b1
interface (ISerializer :: # -> # -> *) clkFreq baudRate = interface (ISerializer :: # -> # -> *) clkFreq baudRate =
putBit8 :: (Bit 8) -> Action {-# always_enabled, always_ready #-} putBit8 :: (Bit 8) -> Action {-# always_enabled, always_ready #-}
bitLineOut :: Bit 1 {-# always_ready #-} bitLineOut :: Bit 1 {-# always_ready #-}
@ -29,8 +29,8 @@ mkSerialize fileHandle = do
addRules $ addRules $
rules rules
{-# ASSERT fire when enabled #-} {-# ASSERT fire when enabled #-}
"ADVANCE UART STATE WHEN NOT IDLE" : when "ADVANCE UART STATE WHEN NOT IDLE" : when
(ftdiState /= IDLE), (ftdiState /= IDLE),
(clkDivider.isAdvancing) ==> (clkDivider.isAdvancing) ==>
do do
ftdiState := ftdiState' ftdiState ftdiState := ftdiState' ftdiState
@ -42,11 +42,10 @@ mkSerialize fileHandle = do
return $ return $
interface ISerializer interface ISerializer
putBit8 bit8Val = putBit8 bit8Val =
do do
clkDivider.reset clkDivider.reset
dataReg := bit8Val dataReg := bit8Val
ftdiState := ftdiState' ftdiState ftdiState := ftdiState' ftdiState
when (ftdiState == IDLE) when (ftdiState == IDLE)
bitLineOut = ftdiTxOut bitLineOut = ftdiTxOut

View file

@ -2,15 +2,15 @@ package State(
State(..), State(..),
ftdiState') where ftdiState') where
data State = IDLE data State = IDLE
| START | START
| DATA (UInt (TLog 8)) | DATA (UInt (TLog 8))
| PARITY | PARITY
| STOP | STOP
deriving (Bits, Eq, FShow) deriving (Bits, Eq, FShow)
ftdiState' :: State -> State ftdiState' :: State -> State
ftdiState' state = ftdiState' state =
case state of case state of
IDLE -> START IDLE -> START
START -> DATA(0) START -> DATA(0)

61
flake.lock Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1735821806,
"narHash": "sha256-cuNapx/uQeCgeuhUhdck3JKbgpsml259sjUQnWM7zW8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d6973081434f88088e5321f83ebafe9a1167c367",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

69
flake.nix Normal file
View file

@ -0,0 +1,69 @@
{
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
utils.url = "github:numtide/flake-utils";
};
outputs =
inputs:
inputs.utils.lib.eachDefaultSystem (
system:
let
pkgs = import inputs.nixpkgs {
localSystem = system;
overlays = [
(final: prev: {
riscv-bluespec-classic = pkgs.callPackage (
{
stdenv,
bluespec,
nextpnr,
openfpgaloader,
trellis,
which,
yosys,
TOPMODULE ? "mkTop",
makeFlags ? [ ],
}:
stdenv.mkDerivation {
pname = "riscv-bluespec-classic";
version = "0.1.0";
src = ./.;
# Versions can be checked with
# `nix eval --json ".#bluespec-joh-template.nativeBuildInputs" | nix-shell -p jq --run jq`
nativeBuildInputs = [
bluespec
nextpnr
openfpgaloader
trellis
which
yosys
];
# TODO: Build and install something
}
) { };
})
];
};
in
{
packages = {
default = inputs.self.packages."${system}".riscv-bluespec-classic;
riscv-bluespec-classic = pkgs.riscv-bluespec-classic;
};
devShells.default =
with pkgs;
mkShell {
inputsFrom = [ riscv-bluespec-classic ];
};
}
);
}

View file

@ -1,14 +0,0 @@
{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/d34a98666913267786d9ab4aa803a1fc75f81f4d.tar.gz") {} }:
pkgs.mkShell {
buildInputs = [
pkgs.yosys
pkgs.nextpnr
pkgs.bluespec
pkgs.yosys-bluespec
];
shellHook = ''
echo "Dev environment for Manna Chip."
'';
}