<commit_before>// instruction decoder module
package iris2

import (
	"fmt"
)

type DecoderUnit struct {
	running bool
	err     chan error
	out     chan *DecodedInstruction
	in      chan Word
	Error   <-chan error
	Input   chan<- Word
	Control <-chan Word
	Result  <-chan *DecodedInstruction
}

func NewDecoderUnit(control, input <-chan Word) *DecoderUnit {
	var dc DecoderUnit
	dc.err = make(chan error)
	dc.out = make(chan *DecodedInstruction)
	dc.in = make(chan Word)
	dc.Error = dc.err
	dc.Input = dc.in
	dc.Control = control
	dc.Result = dc.out
	return &dc
}

func (this *DecoderUnit) Startup() error {
	if this.running {
		return fmt.Errorf("Can't startup an already running decoder unit")
	} else {
		this.running = true
		go this.body()
		go this.controlQuery()
		return nil
	}
}
func (this *DecoderUnit) controlQuery() {
	<-this.Control
	if err := this.shutdown(); err != nil {
		this.err <- err
	}
}
func (this *DecoderUnit) body() {
	for this.running {
		select {
		case raw, more := <-this.in:
			if more {
				// decode the instruction
				raw--
			}
		}
	}
}
func (this *DecoderUnit) shutdown() error {
	if !this.running {<commit_msg>Import an iris16 core in to iris2 to act as decoder<commit_after>// instruction decoder module
package iris2

import (
	"fmt"
	"github.com/DrItanium/cores/iris16"
)

type DecoderUnit struct {
	core    *iris16.Core
	err     chan error
	out     chan *DecodedInstruction
	in      chan Word
	Error   <-chan error
	Input   chan<- Word
	Control <-chan Word
	Result  <-chan *DecodedInstruction
}

func NewDecoderUnit(control <-chan Word) (*DecoderUnit, error) {
	var dc DecoderUnit
	if core, err := iris16.New(); err != nil {
		return nil, err
	} else {
		dc.core = core
		// need to install the microcode somehow
	}

	dc.err = make(chan error)
	dc.out = make(chan *DecodedInstruction)
	dc.in = make(chan Word)
	dc.Error = dc.err
	dc.Input = dc.in
	dc.Result = dc.out
	dc.Control = control
	return &dc
}

func (this *DecoderUnit) Startup() error {
	if this.running {
		return fmt.Errorf("Can't startup an already running decoder unit")
	} else {
		this.running = true
		go this.body()
		go this.controlQuery()
		return nil
	}
}
func (this *DecoderUnit) controlQuery() {
	<-this.Control
	if err := this.shutdown(); err != nil {
		this.err <- err
	}
}
func (this *DecoderUnit) body() {
	for this.running {
		select {
		case raw, more := <-this.in:
			if more {
				// an instruction in iris2 is 64-bits long but
				// it can either be a packet or a single long
				// instruction, this is determined by the group
				// bits at the front of the instruction

			}
		}
	}
}
func (this *DecoderUnit) shutdown() error {
	if !this.running {
{'fraction_non_alphanumeric': 0.11514018691588786, 'fraction_numerical': 0.005233644859813084, 'mean_word_length': 3.066869300911854, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '456234', 'n_tokens_mistral': 1000, 'n_tokens_neox': 915, 'n_words': 301}